Hi all
after working with my self-written db-access layer i just started
using the ContentProvider as suggested by android.
I implemented all db-access functions which i had in a class that
inherits from DatabaseContentProvider and added some of my own public
methods. These help me to initialize my database by reading stuff from
a xml file. I need to call this method explicitly after the xml file
is read. The Problem is, that i can't get my
SelfWrittenContentProvider out of the Context.
i tried with:

SelfWrittenContentProvider p =
(SelfWrittenContentProvider)getContentResolver().getProvider(URI) ;

but this just returns an interface and if i try to cast it i get a
ClassCastException! I tried to instantiate it with

new SelfWrittenContentProvider();

but it does not work either, because the DatabaseHelper (as in the
NotepadExample)  gives me a null-Database. i don't see why i need 2
instances anyway. the ContentProvider gets instantiated just as the
application starts, right? How can i reach it, for example in an
Activity or from a Context object?

or did i misunderstand the whole use of those ContentProviders? What
is the proper way to access a database? Please help me. i refactored
my whole code that i can use those ContentProviders and now i don't
know how to explicitly get them in my code....

Thanks a lot
simon

--~--~---------~--~----~------------~-------~--~----~
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
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to