On Mon, May 18, 2009 at 6:39 AM, Matt Williams <[email protected]> wrote:
>
> The application context itself is not available to the DBAdapter
> singleton.

Why not? Can't you pass it in when you create it?

> 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?

A content provider doesn't make much sense in my opinion if you only
need this data within your own application. If you need to make it
available to other applications as well, then a content provider would
usually be the preferred way.

> 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.

ContentProvider is single threaded, so it'll automatically be
synchronized, but you'd have the same issue with the various threads
having to wait for access.

> 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?

You'd normally give the Context to the object, e.g. via its constructor.

--~--~---------~--~----~------------~-------~--~----~
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