ListActivity and SQLiteDB problem - can't refresh list

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

ListActivity and SQLiteDB problem - can't refresh list

Postby hilly » Thu Oct 29, 2009 11:12 am

Hi,

It will be great if someone here will know how to help me with the issue bellow.

What is the best way to display a database queries results on the screen using ListActivity? I need the db queries to run in the background and I also need to be able to make different queries and refresh the screen according to the query result.

I am using the ListActivity class with a SimpleCursorAdapter in order to display the db queries result on the screen.
At the moment, I am doing the db queries at the background using AsyncTask, when getting the results I want the list to be updated immediately, but I can't find a good way to do it.
It worked only when I used the changeCursor(cursor) function to set the adapter to a new cursor with the new results. But I don't think this is a good solution since it seems to stuck the UI for a while.
I also found some posts about notifyDataSetChanged() but I am not sure if/how/when I should be using it with a SimpleCursorAdapter to make the view refresh.

Can anyone tell what I am doing wrong? Or give a code example or link to something like this that works?

Thanks!
Hilly
hilly
Freshman
Freshman
 
Posts: 2
Joined: Thu Oct 29, 2009 10:51 am

Top

Postby Droid123 » Sat Nov 21, 2009 1:47 pm

same problem here, anyone?
Droid123
Experienced Developer
Experienced Developer
 
Posts: 77
Joined: Sat Nov 21, 2009 1:21 pm

Postby divestoclimb » Tue Nov 24, 2009 7:41 pm

You can call requery() on the Cursor, as long as the query itself has not changed.

In my ListActivities I either call requery() or swap out the Cursor with changeCursor, depending on what just changed. I haven't tried either on a list more than about 20 entries long, though.
divestoclimb - Android SCUBA app developer
Android Community | Gas Mixer, ScubaLib, Scuba Tanks | d2c Checklist
All code is open source under Apache license.
divestoclimb
Developer
Developer
 
Posts: 33
Joined: Mon May 11, 2009 7:46 pm

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 7 guests