android java mysql : Trouble with Data Loss when moving from Activity to Activity where each one performs an HTTP >php > mysql call
<p><strong>UPDATE</strong></p>

<p>I am still debugging this issue and still have not found a solution. Here are some more details:</p>

<p>I am not using XML or JSON to retrieve data in my original implimentatin. I have a custom php script that runs from my server, and I have edited the code to parse the database query into a Java string that can easily be parsed into a String Array using the .split(","); command. ex: $return="item 1,item 2,item 3,item 4"; (see the code below)</p>

<p>The data is coming back accurately from the database in Act 3, which returns an array in the format I specified above, then the data only partially comes back for Act 4: the last item on the list does not return data. Then on Act 5 no data is returned and not errors are thrown. I've tried pretty much everything to debug and am at a loss. </p>

<p>/////////////////////////////////////////////////////////////////////////////</p>

<p>As the title states, I am having trouble in my app where I am navigating from one Activity to another where each one calls to a php, then to a database and returns information. See this diagram:</p>

<blockquote>
  <ul>
  <li>Activity 1: ListActivity, builds a list from local xml</li>
  <li>Activity 2: ListActivity, builds a list from local xml</li>
  <li>Activity 3: ListActivity, gets data from a mysql database (HttpClient to
  php file to db) and uses it to build a
  list</li>
  <li>Activity 4: ListActivity, gets data from a mysql database using data from Activity 3 (HttpClient to
  php file to db) and uses it to build
  another list</li>
  <li>Activity 5: Activity, gets data from a mysql database using data from Activity 4 (HttpClient to php
  file to db) and displays it as a
  TextView.</li>
  </ul>
</blockquote>

<p>The problem is that by the time I get to Activity 5, the data does not return; I get a blank return. I am sending vars to a php script which has been web tested and indeed operates and returns the data correctly. Further, I have alerted all of my data to insure the right vars are being sent to the php files.</p>

<p>Without seeing 5 java docs of code, can any experts, or just anyone, perhaps tell me if I am breaking a cardinal Android / Java rule here?</p>

<p>Added the code for the Activities below:: </p>

<pre><code>private String KEY_121 = "my php file";

public class db_receive extends ListActivity {
  public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.db_layout);
  String results = getServerData(KEY_121);
  String[] list = results.toString().split(",");
  setListAdapter(new ArrayAdapter&lt;String&gt;(this, R.layout.list_item, list));
}


private String getServerData(String returnString) {
    InputStream is = null;
    String result = "";
ArrayList&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
nameValuePairs.add(new BasicNameValuePair(ret_att1,ret_data1));
//http post
try{
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost(KEY_121);
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity entity = response.getEntity();
        is = entity.getContent();
}catch(Exception e){
          Log.e("log_tag", "Error in http connection "+e.toString());
    }

    //convert response to string
    try{
            BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-859-1"),8);
            StringBuilder sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                    sb.append(line + "\n");
            }
            is.close();
            result=sb.toString();
    }catch(Exception e){
            Log.e("log_tag", "Error converting result "+e.toString());
    }
    returnString = result;
    return returnString; 
}
</code></pre>

<p>That is the basic layout of all 3 Activities that send queries to a php file (which grabs data from database) and receivse data, then performs a function. The last Activity is a TextView as opposed to a ListView.</p>
