Note that getLocalContentProvider is API level 5.
If this was my code, I'd take advantage of the provider being local, and
keep a reference to "the" database somewhere (in a static variable). The
provider would use this static to access the database.
In the update code, I'd get the database from the static, and do the
close/copy/open song-and-dance with it.
That way, the content provider would run "on top of" the database
"layer", not the other way around. But that's really just architectural
nitpicking :)
-- Kostya
07.08.2011 20:22, CocoRambo пишет:
> I finally find a solution but I am not proud of it...
>
> My mistake was that I called close() on the wrong SQLiteOpenHelper.
> So I add a public method to my ContentProvider to get his
> SQLiteOpenHelper...
> Next during update I do this:
>
> MyContentProvider cp = (MyContentProvider) context.getContentResolver()
> .acquireContentProviderClient(CONTENT_URI)
> .getLocalContentProvider();
> if (cp != null) {
> cp.getOpenHelper().close();
> }
>
>
> Is there any clean way to do that? (Except your intelligent merge
> solution)
> --
> 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
--
Kostya Vasilyev
--
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
No comments:
Post a Comment