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 6746393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:19:03+00:00 2026-05-26T12:19:03+00:00

I have an Android application that displays a list of names using checkboxes. I

  • 0

I have an Android application that displays a list of names using checkboxes. I want to store the checked items and the unchecked items in my databases . I don’t want to store any data item permanently on the phone. I require a mechanism by which I can store the data (checked and unchecked) temporarily on the phone and then transfer it to database via a web service.

Can anyone tell me how to go about doing this ? What modifications should I do to my current code?

Here is my Android code that displays the list :

      package com.demo;

      import java.io.IOException;
      import java.io.UnsupportedEncodingException;
      import java.net.SocketException;
      import java.util.ArrayList;
      import java.util.List;
      import org.apache.http.NameValuePair;
      import android.app.Activity;
      import android.app.AlertDialog;
      import an droid.content.DialogInterface;
      import android.os.Bundle;
      import android.util.Log;
      import android.widget.TextView;
      import org.apache.http.client.entity.UrlEncodedFormEntity; 
      import org.apache.http.HttpEntity;
      import org.apache.http.HttpResponse;
      import org.apache.http.client.ClientProtocolException;
      import org.apache.http.client.HttpClient;
      import org.apache.http.client.methods.HttpPost;
      import org.apache.http.impl.client.DefaultHttpClient;
      import org.apache.http.message.BasicNameValuePair;
      import org.apache.http.protocol.HTTP;
      import org.json.JSONArray;
      import org.json.JSONException;
      import org.json.JSONObject;
      import org.ksoap2.SoapEnvelope;
      import org.ksoap2.serialization.SoapObject;
      import org.ksoap2.serialization.SoapPrimitive;
      import org.ksoap2.serialization.SoapSerializationEnvelope;
      import org.ksoap2.transport.HttpTransportSE;



 public class TestApp extends Activity {

private static final String SOAP_ACTION = "http://tempuri.org/getData";

    private static final String METHOD_NAME = "getData";

    private static final String NAMESPACE = "http://tempuri.org/";
    private static final String URL = "http://10.0.2.2/getdata2/Service1.asmx";
    TextView tv;

boolean[] bln1=null; 

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    tv=(TextView)findViewById(R.id.text1);

           String[] arr2= call();


           boolean[] bln=new boolean[arr2.length];
    for(int i=0;i<arr2.length;i++)
   {  
        bln[i]=false;

    }  

   bln1 = new boolean[arr2.length];

    new AlertDialog.Builder(TestApp.this)
    .setIcon(R.drawable.alert_dialog_icon)
    .setTitle("Title")
    .setMultiChoiceItems(arr2,
            bln,
            new DialogInterface.OnMultiChoiceClickListener() {
                public void onClick(DialogInterface dialog, int whichButton,
                        boolean isChecked) {

                                        if(isChecked){
                                    bln1[whichButton] = true;
                                           }
                    else{
                        bln1[whichButton] = false;
                    }
                }
            })
    .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {

            JSONObject jsonObject = new JSONObject();
            String[] arr2=call();
            for(int i=0;i<arr2.length;i++)
                try {
                    jsonObject.put("key"+i,arr2[i]);
                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

            JSONArray jArrayParam = new JSONArray();
            jArrayParam.put(jsonObject);

            List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>();
            nameValuePair.add(new BasicNameValuePair("bulkdata",
                    jArrayParam.toString()));

            Log.e("bulkdata", jArrayParam.toString());

        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://10.0.2.2/login2/Service1.asmx");//web service to send data to to forward to database

        httppost.addHeader("Content-Type", "application/x-www-form-urlencoded");
        try {
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePair,  HTTP.UTF_8));
        } catch (UnsupportedEncodingException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        // Execute HTTP Post Request

        try {
            HttpResponse response=null;
            response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();
            Log.e("entity:",entity.toString());
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        // get response entity

        }
    })
    .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {


        }
    })
   .show();


}


public String[] call()
{
    SoapPrimitive responsesData = null; 

    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope( 
    SoapEnvelope.VER11); 
    envelope.dotNet = true; 
    envelope.setOutputSoapObject(request);

    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    androidHttpTransport.debug = true; 

    try {

    androidHttpTransport.call(SOAP_ACTION, envelope);

    responsesData = (SoapPrimitive) envelope.getResponse(); 
    System.out.println(" --- response ---- " + responsesData); 

    } catch (SocketException ex) { 
    ex.printStackTrace(); 
    } catch (Exception e) { 
    e.printStackTrace(); 
    } 
    System.out.println( " ----" + responsesData );

    String serviceResponse= responsesData .toString(); 


    String[] temp; 
    String delimiter = "#"; 
    temp= serviceResponse.split(delimiter);
    System.out.println( " ---- length ---- " + temp.length); 

    return temp; 

                }

         } 

My output till now

  • 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-26T12:19:04+00:00Added an answer on May 26, 2026 at 12:19 pm

    I suppose the error is in the .setPositiveButton() method, in the line String[] arr2=call().

    Why are you reading again data from your webservice, like you did in the onCreate method, and putting it the the json result?

    Shouldn’t you put in json result checkbox status, instead of original data?

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

Sidebar

Related Questions

I have an android app that displays a list of items in a Custom
I want to build an notepad-style application on android that will have syntax highlighting.
I want to develop an android application, that displays live cricket scores as well
I have an application that displays a ListView using a CursorAdapter that I have
I currently have an Android application that displays a schedule for a ferry boat.
I have an Android application that connects to Facebook to request authorization of an
I have a Web Service and an Android application that uses this web service.
I want to integrate the zxing source code to my Android application. I have
I have made an application which calls the phone's contact list but i want
I'm writing my first Android application and I have one activity that I'd like

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.