Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First of all, if you need to pass a lot of data, regardless of the format, it will be slow. How slow is "too slow" is up to your specific application and its requirements. You should do all the HTTP communication in an <code>AsyncTask</code> or another non-UI thread to keep the UI responsive. Displaying a progress dialog, even an indeterminate, would be a nice way of showing to the user that something is going on. </p> <p>Now, for your specific question. I would suggest creating a JSON array of your Strings to check. This will essentially give you one String containing all the data. Set this string as the value for a <code>NameValuePair</code> with whatever name you want and pass this NameValuePair as the HTTP Post entity to your server. Then in your PHP, you can simply do: <code>$valuesToCheck = json_decode($_POST['name'])</code> - and you'll have an array in your <code>$valuesToCheck</code> variable.</p> <p>Now you can do whatever you need to do in PHP and get your data in PHP, for example, you can end up with an array of arrays, say <code>$dataToSend</code> would be an array where each element would be the result of calling <code>mysql_fetch_assoc</code> - or any other way. Once you have this data, simply do this in PHP:</p> <pre><code>header("Content-type: text/json"); echo json_encode($dataToSend); </code></pre> <p>This will send all your data back to your calling code (Android in this case). Finally, in Android, get the response and JSON-decoded it. If you got back an empty array, then there were no matches in the database. If the array is not empty, then you got your data and do whatever you need with it.</p> <p>There are plenty blogs/tutorials/etc. on the web about encoding/decoding JSON in Android. For example, you can refer to <a href="http://www.hdelossantos.com/2009/12/24/quick-and-easy-android-http-post-of-json-string/" rel="nofollow">this one</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload