On Apr 7, 9:23 am, Dianne Hackborn <hack...@android.com> wrote:
>
> You should never open a database multiple times.  
>

Let me make sure I understand this rule.

It seems reasonable to pass an intent:
+ A path to a database
+ A key to find information in said database.

Then the activity will create a list, form etc, after creating an
SQLiteDatabase and then a cursor. It will then make sure that it
closes the cursor and close the SQliteDatabase at the appropriate spot
in its lifecycle.

But if you have multiple activities, this would violate the rule about
opening a database multiple times.

You would pretty much have to have a static factory that keeps track
of open databases in a hashtable, keyed by filename, with reference
counting. Am I right?

As has been noted in these forums, a ContentProvider *never* closes a
database because is there is no call on its interface to do so. I
haven't been using contentproviders but this seems bad, and will
definitely leave red messages in your log.


Nathan

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to