0

这是我的日志消息

    09-17 14:27:45.203: E/Database(12311): close() was never explicitly called on database '/data/data/com.param.calltracker/databases/calls' 
    09-17 14:27:45.203: E/Database(12311): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
    09-17 14:27:45.203: E/Database(12311):  at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1847)
    09-17 14:27:45.203: E/Database(12311):  at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:820)
    09-17 14:27:45.203: E/Database(12311):  at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:854)
    09-17 14:27:45.203: E/Database(12311):  at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:847)
    09-17 14:27:45.203: E/Database(12311):  at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:544)
    09-17 14:27:45.203: E/Database(12311):  at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203)
    09-17 14:27:45.203: E/Database(12311):  at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203)
    09-17 14:27:45.203: E/Database(12311):  at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:118)
    09-17 14:27:45.203: E/Database(12311):  at com.param.calltracker.DatabaseHelper.getUnsendData(DatabaseHelper.java:94)
    09-17 14:27:45.203: E/Database(12311):  at com.param.calltracker.InternetChecker.onReceive(InternetChecker.java:52)
    09-17 14:27:45.203: E/Database(12311):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:1794)
    09-17 14:27:45.203: E/Database(12311):  at android.app.ActivityThread.access$2400(ActivityThread.java:117)
    09-17 14:27:45.203: E/Database(12311):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:981)
    09-17 14:27:45.203: E/Database(12311):  at android.os.Handler.dispatchMessage(Handler.java:99)
    09-17 14:27:45.203: E/Database(12311):  at android.os.Looper.loop(Looper.java:123)
    09-17 14:27:45.203: E/Database(12311):  at android.app.ActivityThread.main(ActivityThread.java:3683)
    09-17 14:27:45.203: E/Database(12311):  at java.lang.reflect.Method.invokeNative(Native Method)
    09-17 14:27:45.203: E/Database(12311):  at java.lang.reflect.Method.invoke(Method.java:507)
    09-17 14:27:45.203: E/Database(12311):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    09-17 14:27:45.203: E/Database(12311):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    09-17 14:27:45.203: E/Database(12311):  at dalvik.system.NativeStart.main(Native Method)
    09-17 14:27:45.283: E/Database(12311): close() was never explicitly called on database '/data/data/com.param.calltracker/databases/calls' 
    09-17 14:27:45.283: E/Database(12311): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
    09-17 14:27:45.283: E/Database(12311):  at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1847)
    09-17 14:27:45.283: E/Database(12311):  at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:820)
    09-17 14:27:45.283: E/Database(12311):  at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:854)
    09-17 14:27:45.283: E/Database(12311):  at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:847)
    09-17 14:27:45.283: E/Database(12311):  at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:544)
    09-17 14:27:45.283: E/Database(12311):  at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203)
    09-17 14:27:45.283: E/Database(12311):  at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203)
    09-17 14:27:45.283: E/Database(12311):  at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:118)
    09-17 14:27:45.283: E/Database(12311):  at com.param.calltracker.DatabaseHelper.getUnsendData(DatabaseHelper.java:94)
    09-17 14:27:45.283: E/Database(12311):  at com.param.calltracker.InternetChecker.onReceive(InternetChecker.java:52)
    09-17 14:27:45.283: E/Database(12311):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:1794)
    09-17 14:27:45.283: E/Database(12311):  at android.app.ActivityThread.access$2400(ActivityThread.java:117)
    09-17 14:27:45.283: E/Database(12311):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:981)
    09-17 14:27:45.283: E/Database(12311):  at android.os.Handler.dispatchMessage(Handler.java:99)
    09-17 14:27:45.283: E/Database(12311):  at android.os.Looper.loop(Looper.java:123)
    09-17 14:27:45.283: E/Database(12311):  at android.app.ActivityThread.main(ActivityThread.java:3683)
    09-17 14:27:45.283: E/Database(12311):  at java.lang.reflect.Method.invokeNative(Native Method)
    09-17 14:27:45.283: E/Database(12311):  at java.lang.reflect.Method.invoke(Method.java:507)
    09-17 14:27:45.283: E/Database(12311):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    09-17 14:27:45.283: E/Database(12311):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    09-17 14:27:45.283: E/Database(12311):  at dalvik.system.NativeStart.main(Native Method)
    09-17 14:27:45.673: E/Database(12311): close() was never explicitly called on database '/data/data/com.param.calltracker/databases/calls' 
    09-17 14:27:45.673: E/Database(12311): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
    09-17 14:27:45.673: E/Database(12311):  at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1847)
    09-17 14:27:45.673: E/Database(12311):  at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:820)
    09-17 14:27:45.673: E/Database(12311):  at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:854)
    09-17 14:27:45.673: E/Database(12311):  at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:847)
    09-17 14:27:45.673: E/Database(12311):  at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:544)
    09-17 14:27:45.673: E/Database(12311):  at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203)
    09-17 14:27:45.673: E/Database(12311):  at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203)
    09-17 14:27:45.673: E/Database(12311):  at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:118)
    09-17 14:27:45.673: E/Database(12311):  at com.param.calltracker.DatabaseHelper.getUnsendData(DatabaseHelper.java:94)
    09-17 14:27:45.673: E/Database(12311):  at com.param.calltracker.InternetChecker.onReceive(InternetChecker.java:52)
    09-17 14:27:45.673: E/Database(12311):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:1794)
    09-17 14:27:45.673: E/Database(12311):  at android.app.ActivityThread.access$2400(ActivityThread.java:117)
    09-17 14:27:45.673: E/Database(12311):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:981)
    09-17 14:27:45.673: E/Database(12311):  at android.os.Handler.dispatchMessage(Handler.java:99)
    09-17 14:27:45.673: E/Database(12311):  at android.os.Looper.loop(Looper.java:123)
    09-17 14:27:45.673: E/Database(12311):  at android.app.ActivityThread.main(ActivityThread.java:3683)
    09-17 14:27:45.673: E/Database(12311):  at java.lang.reflect.Method.invokeNative(Native Method)
    09-17 14:27:45.673: E/Database(12311):  at java.lang.reflect.Method.invoke(Method.java:507)
    09-17 14:27:45.673: E/Database(12311):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    09-17 14:27:45.673: E/Database(12311):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    09-17 14:27:45.673: E/Database(12311):  at dalvik.system.NativeStart.main(Native Method)
    09-17 14:27:46.033: E/Database(12311): close() was never explicitly called on database '/data/data/com.param.calltracker/databases/calls' 
    09-17 14:27:46.033: E/Database(12311): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
    09-17 14:27:46.033: E/Database(12311):  at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1847)
    09-17 14:27:46.033: E/Database(12311):  at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:820)
    09-17 14:27:46.033: E/Database(12311):  at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:854)
    09-17 14:27:46.033: E/Database(12311):  at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:847)
    09-17 14:27:46.033: E/Database(12311):  at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:544)
    09-17 14:27:46.033: E/Database(12311):  at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203)
    09-17 14:27:46.033: E/Database(12311):  at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203)
    09-17 14:27:46.033: E/Database(12311):  at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:118)
    09-17 14:27:46.033: E/Database(12311):  at com.param.calltracker.DatabaseHelper.getUnsendData(DatabaseHelper.java:94)
    09-17 14:27:46.033: E/Database(12311):  at com.param.calltracker.InternetChecker.onReceive(InternetChecker.java:52)
    09-17 14:27:46.033: E/Database(12311):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:1794)
    09-17 14:27:46.033: E/Database(12311):  at android.app.ActivityThread.access$2400(ActivityThread.java:117)
    09-17 14:27:46.033: E/Database(12311):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:981)
    09-17 14:27:46.033: E/Database(12311):  at android.os.Handler.dispatchMessage(Handler.java:99)
    09-17 14:27:46.033: E/Database(12311):  at android.os.Looper.loop(Looper.java:123)
    09-17 14:27:46.033: E/Database(12

311):   at android.app.ActivityThread.main(ActivityThread.java:3683)
09-17 14:27:46.033: E/Database(12311):  at java.lang.reflect.Method.invokeNative(Native Method)
09-17 14:27:46.033: E/Database(12311):  at java.lang.reflect.Method.invoke(Method.java:507)
09-17 14:27:46.033: E/Database(12311):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-17 14:27:46.033: E/Database(12311):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-17 14:27:46.033: E/Database(12311):  at dalvik.system.NativeStart.main(Native Method)

我已cursor正确关闭但仍显示错误 close() was never explicitly called on database

帮我..

4

2 回答 2

1

只需将此代码添加到您的进程结束或您要关闭数据库的位置。

    DatabaseHelper dbHelper;

    db = dbHelper.getWritableDatabase(); 
    db.close();

    or

   dbHelper.getReadableDatabase().close();
于 2013-10-08T07:50:32.103 回答
0

onDestroy()使用打开数据库的同一实例在方法中关闭数据库:

@Override
protected void onDestroy() {
    super.onDestroy();
    // Close the database here
}
于 2013-09-17T13:46:31.237 回答