Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6851167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:12:53+00:00 2026-05-27T01:12:53+00:00

My requirement is : I want to upload the sqlite table records to MS

  • 0

My requirement is :

I want to upload the sqlite table records to MS SQL server.I have service.Normal Uploading alos working fine(Normal uploading means after login , it will show list of upload table information.When the user click upload button, it upload & go to next screen). Now i want to do this: sale rep save invoice/payment then service start & upload data in the backend sql server without effecting rest of the code.

I did like this :

    public class UploadService extends Service {
  private static final String TAG = "UploadService";
  public static final String APPURL = "http://192.168.1.213:7986/XontService";
  private static final String NAMESPACE = "http://tempuri.org/";
  private static final String METHOD_NAME = "convertJSONToDataSet";
  private static String SOAP_ACTION = "http://tempuri.org/IXontService/convertJSONToDataSet";
  ArrayList<String> uploadFiler = new ArrayList<String>();  
  HashMap<Integer,String> uploadTable = new HashMap<Integer, String>();

  @Override
  public IBinder onBind(Intent arg0) {
    return null;
  }

  @Override
  public void onCreate() {
    Toast.makeText(this, "Upload Service Created", Toast.LENGTH_LONG).show();
    Log.d(TAG, "onCreate");
    uploadUsingService();

  }

  @Override
  public void onDestroy() {
    Toast.makeText(this, "Upload Service Stopped", Toast.LENGTH_LONG).show();
    Log.d(TAG, "onDestroy");
  }

  @Override
  public void onStart(Intent intent, int startid) {
    Toast.makeText(this, "Upload Service Started", Toast.LENGTH_LONG).show();
    Log.d(TAG, "onStart");

  }


  public void uploadUsingService(){
    uploadTable = getUploadTable();
    if(uploadTable.size() > 0){
      for (Map.Entry<Integer, String> entry : uploadTable.entrySet()) {
        System.out.println("----key" + entry.getKey());
         String value = entry.getValue();

         if(value.equals("WMInvoiceHeader")){
           getInvoiceHeader();
         }
      }
    }
  }

  public void getInvoiceHeader(){
    boolean serviceStatus =true;
    DBAdapter dbAdapter = DBAdapter.getDBAdapterInstance(this);
    //  dbAdapter.openDataBase();

     SharedPreferences myPrefs = this.getSharedPreferences("myLogedPrefs",MODE_PRIVATE);
      String  strBusinessUnit = myPrefs.getString("BusinessUnit", "");
      String  strExecutive = myPrefs.getString("Executive", "");

      try{
        StringBuffer invoiceHeader = new StringBuffer();
      JSONArray jaHeader = new JSONArray();
      String query = "SELECT BusinessUnit,ExecutiveCode,InvoiceNo,SalesCategory,RetailerCode," +//4
              " RetailerCodeSon,InvoiceDate,GrossValue,InvoiceValue,TotalLineDiscount," + //9
              " TotalHeaderDiscount,VATValue,UpdatedOn,UpdatedBy,UploadFlag,VisitNumber ," + //15
              " VisitSequence,RouteCode,SalesType,ActiveStatus,UploadedOn,UploadedBy,UploadedMethod," +
              " UploadedType,RetailerType,HeaderDiscountFlag,SpecialDiscountFlag,TXNReference,TourReference" +
              " FROM WMInvoiceHeader " +
              " WHERE (CancelFlag IS NULL OR CancelFlag ='0')";
         ArrayList<?> stringList = dbAdapter.selectRecordsFromDBList(query, null);
       if(stringList.size() > 0){
        invoiceHeader.append("{\"WMInvoiceHeader\":");
           for (int i = 0; i < stringList.size(); i++) {
             ArrayList<?> arrayList = (ArrayList<?>) stringList.get(i);
             ArrayList<?> list = arrayList;
             JSONObject invHeader = new JSONObject();
             invHeader.put("BusinessUnit",(String)list.get(0));
             invHeader.put("ExecutiveCode",(String)list.get(1));
             invHeader.put("InvoiceDate",(String)list.get(6));
             invHeader.put("VisitSequence",(String)list.get(16));
             invHeader.put("RouteCode",(String)list.get(17));
             invHeader.put("SalesType",(String)list.get(18));         
           jaHeader.put(invHeader);
           }
       }
      invoiceHeader.append(jaHeader.toString());
      invoiceHeader.append("}");
      serviceStatus = soapPrimitiveData("WMInvoiceHeader", strBusinessUnit, strExecutive, invoiceHeader.toString());

        }catch (IOException e) {
        serviceStatus =false;
        e.printStackTrace();
      } catch (XmlPullParserException e) {
        serviceStatus =false;
        e.printStackTrace();
      }catch (Exception e) {
        serviceStatus =false;
        e.printStackTrace();
      }finally{
        if(!serviceStatus){
          uploadFiler.add("WMInvoiceHeader");
        }
      }


  }

  public boolean soapPrimitiveData(String tablename,String strBusinessUnit, String strExecutive,String jsonString) throws IOException,XmlPullParserException {
    SoapPrimitive responsesData = null;
    boolean status =false;
    SoapObject requestData = new SoapObject(NAMESPACE, METHOD_NAME); // set
    requestData.addProperty("strBusinessUnit", strBusinessUnit);
    requestData.addProperty("strExecutiveCode", strExecutive);
    requestData.addProperty("strTableName", tablename);
    requestData.addProperty("jsonContent", jsonString);
    SoapSerializationEnvelope envelopes = new SoapSerializationEnvelope(SoapEnvelope.VER11); // put all required data into a soap//// envelope
    envelopes.dotNet = true;
    envelopes.setOutputSoapObject(requestData);
    AndroidHttpTransport httpTransport = new AndroidHttpTransport(APPURL);
    httpTransport.debug = true;
    try {
      httpTransport.call(SOAP_ACTION, envelopes);
      responsesData = (SoapPrimitive) envelopes.getResponse();
      if((responsesData.toString()).equals("true")){
        DBAdapter dbAdapter = DBAdapter.getDBAdapterInstance(UploadService.this);
         status = dbAdapter.updateUploadedTable(tablename, strExecutive, strBusinessUnit);
      }


    } catch (SocketException ex) {
      status = false;
      Log.e("Error : " , "Error on soapPrimitiveData() " + ex.getMessage());
      ex.printStackTrace();
    } catch (Exception e) {
      status = false;
      Log.e("Error : " , "Error on soapPrimitiveData() " + e.getMessage());
       e.printStackTrace();
      }
    return status;
  }


  public HashMap<Integer,String> getUploadTable(){
    DBAdapter dbAdapter = DBAdapter.getDBAdapterInstance(this);
       dbAdapter.openDataBase();

      SharedPreferences myPrefs = this.getSharedPreferences("myLogedPrefs",MODE_PRIVATE);
    String  strBusinessUnit = myPrefs.getString("BusinessUnit", "");
    String  strExecutive = myPrefs.getString("Executive", "");


       HashMap<Integer,String> uploadTableMap = new HashMap<Integer,String>();
       try {
         String query = "SELECT TableName FROM WMPalmUploadControl WHERE Upload = '1' AND BusinessUnit =? AND ExecutiveCode = ?;";
         String[] d = new String[]{strBusinessUnit,strExecutive};
         ArrayList<?> stringList = dbAdapter.selectRecordsFromDBList(query, d);
       if(stringList.size() > 0){
           for (int i = 0; i < stringList.size(); i++) {
             ArrayList<?> arrayList = (ArrayList<?>) stringList.get(i);
             ArrayList<?> list = arrayList;
             uploadTableMap.put(i, (String)list.get(0));
           }

       }
       dbAdapter.close();

    } catch (Exception e) {
      e.printStackTrace();
    }

    return uploadTableMap;
  }

}

Here i want to call uploadUsingService() method in the onStart().

This is my calling code:

   if(is3g ||isWifi){
            startService(new Intent(this, UploadService.class));
    }else if (networkType == TelephonyManager.NETWORK_TYPE_GPRS) {
            if(signalStrengthInt > 10){  ....}

    }  

When I ran this code :I got this onCreate()' methodToastmessageUpload Service Created. 'onStart()` Toast message not display. How can i call this. I did this part from this Link

Please anybody help me out from this issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:12:54+00:00Added an answer on May 27, 2026 at 1:12 am

    service.onStart has been deprecated since Android 2.0. Perhaps it’s no longer called in the version you’re using. Read this: http://android-developers.blogspot.com/2010/02/service-api-changes-starting-with.html

    Use service.onStartCommand instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a requirement that I want to check the request headers and according
I have a requirement in sharepoint where I want to Create the top link
Here's my requirement: 1. I want my installable to have a custom license agreement
Requirement is this ... We have our 3 web-applications deployed in RHEL-5 server, we
Requirement : Should update MySQL database with that of MS Sql Server updates which
My requirement is I have server J2EE web application and client J2EE web application.
I want my site to have a feature for users to upload images, but
I have requirement where in i want to download the files from different machines
I want to create a simple file upload server. The server should be able
Hello Friends I want to upload a image but according to requirement when click

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.