When to close database in ContentProvider

by Wah » Sun, 01 Mar 2009 16:10:59 GMT


Sponsored Links
 I am trying to write a ContentProvider which itself is based on a
SqlLite database. I am puzzled when I need to close the database
because ContentProvider has onCreate( ) function but not onDestroy( )
function.

I downloaded the android source code tree, and found
com.example.codelab.rssexample.RssContentProvider

It appears this class called "openDatabase" but never "close" on it:

=========
    @Override
    public boolean onCreate() {
        ...
        final Context con = getContext();
        try{
            mDb = mDbHelper.openDatabase(getContext(), DATABASE_NAME,
null, DB_V
ERSION);
        ...
     }

=========
mDb.close( ) is never called
=========

If there is no onDestroy() from ContentProvider and we don't call close
( ) on databases, doesn't this lead to some kind of memory/resource
leak?

Wah
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Gyro Sensor development

Hi,

We are developing gyro sensor driver,

We have coded Driver and application now we  are about to integrate
the code.

Here we want to know how the HAL layer is communicating with Android
platform,

We are using Android 2.2.

Do we have support for Gyro sensor in Android 2.2 if not how to port
Gyro sensor specific codes in Android platform

Thanks in adv

Regards
Arun

-- 

2. froyo netd

I just want to know the follow question:
1.what's the role of netd in android
2.why android need this daemon3.what's the difference between netd and inetd in linuxthanks

-- 

3. Overview for which API calls require which permissions?

4. Widget not getting updated.

5. what's meands of oneway interface ?

6. Device Buying Club

7. NFC test hardware for Android 2.3