Hi all,

I have seen that if we use an AbstractSyncableContentProvider (other
providers like ContactProvider use it), a “close()” method is
implemented:
public void close(){
    if(mOpenHelper != null)
        mOpenHelper.close();
}
In this case, the helper seems to be closed (and also de DB), the same
helper that remains open in a ContentProvider. I can’t understand the
lifecycle of the ContentProvider without a method to release all the
things. Any ideas ?.-Thanks in advance.

S.

On 18 ago, 18:00, "S. Mccoy" <mccoy.sher...@gmail.com> wrote:
> Maybe it’s an easy question, but I’ve tried to understand why all the
> content providers seem not to close the DB that they use. In the
> NotePadProvider example (in other providers is similar), it’s used a
> Helper to manage the DB (that extends of SQLiteOpenHelper). This
> helper has a method to close the DB (http://developer.android.com/
> reference/android/database/sqlite/SQLiteOpenHelper.html#close%28%29),
> but in all the providers that I have seen (even in the example), this
> method is never used.
>
> For example, in the query method of the NotPadProvider we use the
> helper to open a DB
>
> // Get the database and run the query         SQLiteDatabase db =
> mOpenHelper.getReadableDatabase();         Cursor c = qb.query(db,
> projection, selection, selectionArgs, null, null,
> orderBy);          // Tell the cursor what uri to watch, so it knows
> when its source data changes         c.setNotificationUri(getContext
> ().getContentResolver(), uri);         return c;
>
> the mOpenHelper is create in the “onCreate()” method, but there is no
> reference to a mOpenHelper.close() in all the provider (maybe because
> there is no “close()” method in ContentProvider).
>
> Do we need to close the SQLiteOpenHelper object? When we use it inside
> a ContentProvider, where is the right place to close it?
>
> Thanks in advance.
> S.
--~--~---------~--~----~------------~-------~--~----~
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