Hi Dianne,
Thank you for the reply.
In this example I'm not sure what the baseUri should be :
Uri baseUri;
if (mCurFilter != null) {
baseUri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI,
Uri.encode(mCurFilter));
} else {
baseUri = Contacts.CONTENT_URI;
}
I have a SQLiteDatabase which I get usually access via a SQLiteOpenHelper. All
the Loader examples I see refer to data stored as a ContentProvider.
Regards,
Julius.
On 30/07/2011, at 6:04 AM, Dianne Hackborn wrote:
> Consider using loaders, for example:
>
> http://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/LoaderCursorSupport.html
>
> On Fri, Jul 29, 2011 at 9:23 AM, Julius Spencer <[email protected]> wrote:
> Hi,
>
> I have been trying to take database reads off the UI thread and am currently
> using an AsyncTask, however I am running into trouble swapping out an updated
> Cursor for a new one in the adapter.
> (I was previously using requery() on the Cursor which had to be on the main
> UI thread)
>
> The documentation regarding requery() says:
> "Just request a new cursor, so you can do this asynchronously and update your
> list view once the new cursor comes back."
>
> If I update the existing Cursor (mCursor) with the results from a new query
> and do the following in onPostExecute of an AsyncTask:
>
> mAdapter.changeCursor(mCursor);
>
> it works pretty well on a Nexus 1. On other devices I am getting errors
> because I haven't closed the old Cursor.
> (java/lang/IllegalStateException;: Finalizing cursor
> android.database.sqlite.SQLiteCursor on null that has not been deactivated or
> closed)
>
> I have tried creating a new Cursor and swapping the Cursors out like so:
>
> if(null!=mArtists)
> mCursor.close();
> mArtists = newCursor;
>
> but I get performance issues and the view of the list goes back to the top.
>
> Has anyone got any ideas on this? Alternatively does anyone have or know of
> any documentation for using a CursorLoader against a SQLiteDatabase rather
> than a ContentProvider?
>
> Thanks for any help.
>
> Regards,
> Julius.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
>
>
> --
> Dianne Hackborn
> Android framework engineer
> [email protected]
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails. All such
> questions should be posted on public forums, where I and others can see and
> answer them.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en