Hi Mark. I don't think that's a most desirable solution. For most
cases, we'd like to have the CursorAdapter (which is attached to
Cursor) populated in runtime with new entries from ContentProvider/
Database.
I generally agree with jsfd that since activity offers managedQuery
method, it would be really niece if elegant solution such as:

onCreate()
{
 ...
 Cursor c = managedQuery("content://authority/path", PROJECTION,
null , ...);
 setListAdapter(new MyCursorAdapter(this, c);
}
would populate adapter on separate thread as soon as new items become
available. But unfortunately, if query takes too long, UI thread will
starve and application may become a candidate for ANR.

What is the most correct way to populate your list items from database/
contentprovider records when querying then takes too long?

On Mar 29, 7:52 pm, Mark Murphy <mmur...@commonsware.com> wrote:
> jsdf wrote:
> > I then thought of trying to load the cursor in a background thread,
> > but realize that this might be problematic, as the CursorAdapter
> > should be instantiated in onCreate() and should take a cursor as a
> > parameter.
>
> Why? Run your query in an AsyncTask and call setListAdapter() in
> onPostExecute() of the task.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> Android 2.x Programming Books:http://commonsware.com/books

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to