The application context itself is not available to the DBAdapter
singleton.

Am I simply taking the wrong approach in managing my applications
access to the database?
Would I be better off with using a content provider, for example? Is
this the preferred method?

Obviously, by using a synchronized singleton, processes will be
waiting for their opportunity to access the database. Will a content
provider automagically manage this for me? My application may attempt
to perform synchronous writes to the database, via multiple background
processes and activities, so this is a priority.

In the book I have it mentioned that you will generally use a content
provider if you want to make the database available to other
applications. Is this one of the cases where i will want to use one
solely for a single application?

That said, how do I simply get the application context from a class
which doesn't extend a base application class? Should I be extending
something anyway?

Kind regards,

Matt

On May 18, 3:46 am, Marco Nelissen <[email protected]> wrote:
> Your application/activity will be given a Context by the system. Use that.
>
> On Sun, May 17, 2009 at 10:36 AM, Makeable <[email protected]> wrote:
>
> > I have just started on a new application that will use SQLite for
> > persistance and Im a bit confused over the usage of a context when
> > utilizing the SQLiteOpenHelper.
>
> > I have a base class called Storable, which my models extend if they
> > need to be persisted.
> > i had intended to use a synchronized singleton database adapter, but I
> > can't for the life of me understand how to utilize the
> > SQLiteOpenHelper as it requires a context, which my models don't
> > appear to possess.
>
> > Im aware that I can get around this by not using the SQLOpenHelper -
> > but if this restriction is in place, I would assume its to prevent
> > people creating apps "the wrong way" for android.
>
> > What is the best practice way for saving models in the database?
>
> > I'm now on my 26th hour of no sleep, so any advice would be very much
> > appreciated :)
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to