upload sqlite data from mobile to serverSupport


  1. gousalya2011

    gousalya2011 New Member

    Hi i have a .Net webservice calling through android mobile using ksoap2 and try to upload the records to server from android sqlite, everything fine and records were uploaded.
    When i clicked the upload button in the mobile 3 records are inserted in the server stock table and column MobileRowId records like 1,1,1 respectively (but i need 1,2,3). Because mobile sqlite having only 3 records.Next time clicked the upload button again 3 records are inserted in stock table and column MobileRowId like 2,2,3 respectively (but i need 1,2,3).
    Here my code as below
    Cursor cur = db.query("tblstk", null, null, null, null, null, null);
    int iCount =cur.getCount();
    if (iCount > 0)
    {
    while(cur.moveToNext()) {
    int SalesPersonID = Integer.parseInt(cur.getString(0));
    int CustomerGroupID = Integer.parseInt(cur.getString(1));
    String CustomerID = cur.getString(2);
    String pDate = cur.getString(3);
    int Balancestock = Integer.parseInt(cur.getString(4));
    String ItemDescription = cur.getString(5);
    String CategoryCode = cur.getString(6);
    String ItemCode =cur.getString(7);
    int Localareacode = Integer.parseInt(cur.getString(8));
    int Cellid = Integer.parseInt(cur.getString(9));
    String TakeDateTime =cur.getString(10);
    int intRowID = Integer.parseInt(cur.getString(11));
    // int intStatusCode
    PropertyInfo pi=new PropertyInfo();
    pi.setName("SalesPersonID");
    pi.setValue(SalesPersonID);
    pi.setType(Integer.class);
    request.addProperty(pi);
    PropertyInfo InfoDate=new PropertyInfo();
    InfoDate.setName("Date");
    InfoDate.setValue(pDate);
    InfoDate.setType(String.class);
    request.addProperty(InfoDate);

    PropertyInfo InfoCustomerID=new PropertyInfo();
    InfoCustomerID.setName("CustomerID");
    InfoCustomerID.setValue(CustomerID);
    InfoCustomerID.setType(String.class);
    request.addProperty(InfoCustomerID);

    PropertyInfo InfoGroup=new PropertyInfo();
    InfoGroup.setName("CustomerGroupID");
    InfoGroup.setValue(CustomerGroupID);
    InfoGroup.setType(Integer.class);
    request.addProperty(InfoGroup);

    PropertyInfo InfoStock=new PropertyInfo();
    InfoStock.setName("Stock");
    InfoStock.setValue(Balancestock);
    InfoStock.setType(Integer.class);
    request.addProperty(InfoStock);

    PropertyInfo Infodescription=new PropertyInfo();
    Infodescription.setName("ItemDescription");
    Infodescription.setValue(ItemDescription);
    Infodescription.setType(String.class);
    request.addProperty(Infodescription);

    PropertyInfo Infocategorycode=new PropertyInfo();
    Infocategorycode.setName("CategoryID");
    Infocategorycode.setValue(CategoryCode);
    Infocategorycode.setType(String.class);
    request.addProperty(Infocategorycode);

    PropertyInfo Infoitemcode=new PropertyInfo();
    Infoitemcode.setName("ItemCode");
    Infoitemcode.setValue(ItemCode);
    Infoitemcode.setType(String.class);
    request.addProperty(Infoitemcode);

    PropertyInfo Infoloacalareacode=new PropertyInfo();
    Infoloacalareacode.setName("LocalAreaCode");
    Infoloacalareacode.setValue(Localareacode);
    Infoloacalareacode.setType(Integer.class);
    request.addProperty(Infoloacalareacode);

    PropertyInfo Infocellid=new PropertyInfo();
    Infocellid.setName("intCellID");
    Infocellid.setValue(Cellid);
    Infocellid.setType(Integer.class);
    request.addProperty(Infocellid);

    PropertyInfo Infotakedatetime=new PropertyInfo();
    Infotakedatetime.setName("takeDate");
    Infotakedatetime.setValue(TakeDateTime);
    Infotakedatetime.setType(String.class);
    request.addProperty(Infotakedatetime);

    PropertyInfo Inforowid=new PropertyInfo();
    Inforowid.setName("MobileStockRowID");
    Inforowid.setValue(intRowID);
    Inforowid.setType(Integer.class);
    request.addProperty(Inforowid);

    SoapSerializationEnvelope senvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    senvelope.setOutputSoapObject(request);
    senvelope.dotNet = true;
    try {
    strSalespersonID = global.getId();
    HttpTransportSE HttpTransport = new HttpTransportSE(URL,TimeOut);
    HttpTransport.call(SOAP_ACTION, senvelope);
    String result =null;
    SoapPrimitive response =null;
    response = (SoapPrimitive)senvelope.getResponse();
    result = response.toString();
    if(result != null)
    {
    String TABLE= "tblstk";
    String KEY_NAME = "ID";
    int iRid = Integer.parseInt(result);
    db.delete(TABLE, KEY_NAME + "=" + iRid, null);
    Cursor curt = db.query("tblstk",null, null, null, null, null, null); int iCountt =curt.getCount();
    Toast.makeText(getApplicationContext(), "Stocks upload successfully",Toast.LENGTH_LONG).show();
    }
    else
    { Toast.makeText(getApplicationContext(), "Server not return value",Toast.LENGTH_LONG).show();
    }

    } catch (Exception e)
    {
    Toast.makeText(getApplicationContext(), e.toString(),Toast.LENGTH_LONG).show();
    strSalespersonID = global.getId();
    errorMessage = e.toString();
    errorlog.LogError("1", "UploadActivity", "InsertStocks", errorMessage.toString(), "", strSalespersonID);

    }

    }
    }
    else
    {
    Toast.makeText(getApplicationContext(), "Records not found",Toast.LENGTH_LONG).show();
    }
    cur.close();
    when I click the upload button for the first time I debug the code, the response returns the same MobileRowId as 1 from the server until upload of 3 records. The 3 records of MobileRowId was 1,2,3 in sqlite.


    when I click the upload button for the Second time
    the response returns the same MobileRowId as 2,2 and 3 from the server until upload of 3 records. The 3 records of MobileRowId was 1,2,3 in sqlite.

    I want inserted records in the server should be shows only 3 records but shows 6 records.
    The same service I was used in windows mobile 6.1 records inserted correctly and fine.
    But in the android I have problem.
    Whats wrong in my code could anybody solve my problem

    [​IMG] Edit [​IMG] Reply [​IMG] Quote [​IMG]

    Advertisement
    Last edited by a moderator: Mar 16, 2015
    #1
  2. EarlyMon

    EarlyMon The PearlyMon Moderator

Share This Page