Friday, January 14, 2011

[android-developers] How best to query web repeatedly.

I run GPS, and query a web based mysql every 50 meters of driving.
People tell me the app locks up and has lag, so I put each query in a
new thread. This seems to create a backlog of threads (at least in the
emulator).

URL url = new URL("http://www.website.org/marks.php");

HttpURLConnection urlConn = (HttpURLConnection) url
.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(
urlConn.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
response.append( inputLine );

1. Are dozens of threads wrong? Do I just use two and leave it at
that?
2. Should I keep connection open as I have heard others speak of?
3. Will I ultimately be forced to sqlite and the new headache of db
synchronization?

Anyone have any experience to offer?

Thanks in advance,
-cellurl

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate