DatabaseNotClosed 异常 - 列表视图滚动

发布于 12-04 10:45 字数 10972 浏览 0 评论 0原文

我有一个由从 SQLite 数据库读取的适配器填充的列表视图。当我在屏幕上的列表中向下滚动时,出现以下错误。当切换到应用程序中的另一个选项卡(它是基于选项卡的应用程序)时,我也会遇到相同的错误。

close() 从未在数据库上显式调用 DatabaseNotClosedException:应用程序未关闭此处打开的游标或数据库对象。

有谁知道为什么会发生这种情况?我在下面发布了主要和适配器类文件。

主类:

public class Home extends ListActivity {

private DataBaseHelper myDbHelper;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.homeaz);

    ListView yourList = (ListView) findViewById(android.R.id.list);

    yourList.setOnItemClickListener(new OnItemClickListener()

    {
                    @Override
                    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

                        Log.e("onClick",""+arg3);
                        Intent i = new Intent(Home.this,DetailView.class);
                        i.putExtra(DataBaseHelper.ID, arg3);
                        // Activity returns an result if called with startActivityForResult

                        /**Home.this.finish();*/
                        startActivity(i);

                        }   
    });


    myDbHelper = new DataBaseHelper(this);

    try {

        myDbHelper.createDataBase();

} catch (IOException ioe) {

    throw new Error("Unable to create database");

}

try {

    myDbHelper.openDataBase();

}catch(SQLException sqle){

    throw sqle;

}

try {

    Cursor cursor = getPlaces();
    showPlaces(cursor);

}

finally {

myDbHelper.close();

}
}

private static String ORDER_BY = NAME + " ASC";

private Cursor getPlaces() {

    SQLiteDatabase db = myDbHelper.getReadableDatabase();
    Cursor cursor = db.query(TABLE_NAME, null, null, null, null, null, ORDER_BY);
    startManagingCursor(cursor);
    return cursor;

}

private void showPlaces(Cursor cursor) {

    MyCustomAdapterClass adapter = new MyCustomAdapterClass(this,cursor, true); setListAdapter(adapter); 

}

适配器类:

public class MyCustomAdapterClass extends CursorAdapter {

public MyCustomAdapterClass(Context context, Cursor c, boolean autoRequery) {
    super(context, c, autoRequery);
    // TODO Auto-generated constructor stub
}

@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return LayoutInflater.from(context).inflate(R.layout.item, parent, false);
}

@Override

public void bindView(View view, Context context, Cursor cursor) {
((TextView) view.findViewById(R.id.name)).setText(cursor.getString(cursor.getColumnIndex("Name")));
((TextView) view.findViewById(R.id.description)).setText(cursor.getString(cursor.getColumnIndex("Area")));
((TextView) view.findViewById(R.id.address)).setText(cursor.getString(cursor.getColumnIndex("AddressLine1")));
switch (cursor.getInt(cursor.getColumnIndex("_id"))) {
case 1:
((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture1);
break;
case 2:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture2);
break;
case 3:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture3);
break;
case 4:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture4);
break;
case 5:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture5);
break;
case 6:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture6);
break;
case 7:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture7);
break;
case 8:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture8);
break;
case 9:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture9);
break;
case 10:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture10);
break;
case 11:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture11);
break;
case 12:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture12);
break;
case 13:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture13);
break;
case 14:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture14);
break;
case 15:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture15);
break;
case 16:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture16);
break;
case 17:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture17);
break;
case 18:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture18);
break;
case 19:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture19);
break;
case 20:

日志:

09-10 18:44:25.495:INFO / ActivityManager(59):启动活动:意图{ cmp = com.Beutelkind.Database / .DetailView(有额外内容)} 09-10 18:44:25.665:DEBUG/dalvikvm(415):GC_EXTERNAL_ALLOC 在 66 毫秒内释放了 4966 个对象/284992 字节 09-10 18:44:26.284:DEBUG/dalvikvm(415):GC_EXTERNAL_ALLOC 在 56 毫秒内释放了 300 个对象/14840 字节 09-10 18:44:27.435:INFO/ActivityManager(59):显示的活动 com.Beutelkind.Database/.DetailView:1888 毫秒(总计 1888 毫秒) 09-10 18:44:28.725:INFO/ActivityManager(59):启动活动:意图 { cmp=com.Beutelkind.Database/.Main } 09-10 18:44:28.825: INFO/Database(415): sqlite 返回: 错误代码 = 14,msg = 无法在源代码行 25467 打开文件 09-10 18:44:28.825:错误/数据库(415):sqlite3_open_v2(“/mnt/sdcard/DatabaseC.sqlite”,&handle,1,NULL)失败 09-10 18:44:29.535:INFO/ActivityManager(59):显示的活动 com.Beutelkind.Database/.Main:781 毫秒(总计 781 毫秒) 09-10 18:44:32.405:DEBUG/dalvikvm(415):GC_EXTERNAL_ALLOC 在 63 毫秒内释放了 2748 个对象/167024 字节 09-10 18:44:32.455:WARN/SQLiteCompiledSql(415):在终结器中释放语句。请确保您在光标上显式调用 close():SELECT DISTINCT _id、Name、Description、Area、Postcode、AddressLine1、OpeningTimes、NearestTube、Cos 09-10 18:44:32.455:WARN / SQLiteCompiledSql(415):android.database.sqlite.DatabaseObjectNotClosedException:应用程序未关闭此处打开的游标或数据库对象 09-10 18:44:32.455:警告/SQLiteCompiledSql(415):在android.database.sqlite.SQLiteCompiledSql。(SQLiteCompiledSql.java:62) 09-10 18:44:32.455:警告/SQLiteCompiledSql(415):在android.database.sqlite.SQLiteProgram。(SQLiteProgram.java:80) 09-10 18:44:32.455:警告/SQLiteCompiledSql(415):在android.database.sqlite.SQLiteQuery。(SQLiteQuery.java:46) 09-10 18:44:32.455:警告/SQLiteCompiledSql(415):在android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42) 09-10 18:44:32.455:警告/SQLiteCompiledSql(415):在android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345) 09-10 18:44:32.455:警告/SQLiteCompiledSql(415):在android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1229) 09-10 18:44:32.455:警告/SQLiteCompiledSql(415):在android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1184) 09-10 18:44:32.455:警告/SQLiteCompiledSql(415):在com.Beutelkind.Database.DetailView.populateFields(DetailView.java:79) 09-10 18:44:32.455:警告/SQLiteCompiledSql(415):在com.Beutelkind.Database.DetailView.onCreate(DetailView.java:70) 09-10 18:44:32.455:警告/SQLiteCompiledSql(415):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 09-10 18:44:32.455:警告/SQLiteCompiledSql(415):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 09-10 18:44:32.455:警告/SQLiteCompiledSql(415):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 09-10 18:44:32.455:警告/SQLiteCompiledSql(415):在android.app.ActivityThread.access$2300(ActivityThread.java:125) 09-10 18:44:32.455:警告/SQLiteCompiledSql(415):在 android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 09-10 18:44:32.455:警告/SQLiteCompiledSql(415):在android.os.Handler.dispatchMessage(Handler.java:99) 09-10 18:44:32.455:警告/SQLiteCompiledSql(415):在android.os.Looper.loop(Looper.java:123) 09-10 18:44:32.455:警告/SQLiteCompiledSql(415):在android.app.ActivityThread.main(ActivityThread.java:4627) 09-10 18:44:32.455:警告/SQLiteCompiledSql(415):在java.lang.reflect.Method.invokeNative(本机方法) 09-10 18:44:32.455:警告/SQLiteCompiledSql(415):在java.lang.reflect.Method.invoke(Method.java:521) 09-10 18:44:32.455:警告/SQLiteCompiledSql(415):在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 09-10 18:44:32.455:警告/SQLiteCompiledSql(415):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 09-10 18:44:32.455:警告/SQLiteCompiledSql(415):在dalvik.system.NativeStart.main(本机方法) 09-10 18:44:32.475:错误/数据库(415):从未在数据库“/data/data/com.Beutelkind.Database/databases/DatabaseC.sqlite”上显式调用 close() 09-10 18:44:32.475:错误/数据库(415):android.database.sqlite.DatabaseObjectNotClosedException:应用程序未关闭此处打开的游标或数据库对象 09-10 18:44:32.475:错误/数据库(415):在android.database.sqlite.SQLiteDatabase。(SQLiteDatabase.java:1810) 09-10 18:44:32.475:错误/数据库(415):在 android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:817) 09-10 18:44:32.475:错误/数据库(415):在 android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:851) 09-10 18:44:32.475:错误/数据库(415):在 android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:844) 09-10 18:44:32.475:错误/数据库(415):在 android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:540) 09-10 18:44:32.475:错误/数据库(415):在 android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203) 09-10 18:44:32.475:错误/数据库(415):在 android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:98) 09-10 18:44:32.475:错误/数据库(415):在 android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:158) 09-10 18:44:32.475:错误/数据库(415):位于 com.Beutelkind.Database.DetailView.populateFields(DetailView.java:77) 09-10 18:44:32.475:错误/数据库(415):在com.Beutelkind.Database.DetailView.onCreate(DetailView.java:70) 09-10 18:44:32.475:错误/数据库(415):在 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 09-10 18:44:32.475:错误/数据库(415):在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 09-10 18:44:32.475:错误/数据库(415):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 09-10 18:44:32.475:错误/数据库(415):在 android.app.ActivityThread.access$2300(ActivityThread.java:125) 09-10 18:44:32.475:错误/数据库(415):在 android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 09-10 18:44:32.475:错误/数据库(415):在 android.os.Handler.dispatchMessage(Handler.java:99) 09-10 18:44:32.475:错误/数据库(415):在android.os.Looper.loop(Looper.java:123) 09-10 18:44:32.475:错误/数据库(415):在android.app.ActivityThread.main(ActivityThread.java:4627) 09-10 18:44:32.475:错误/数据库(415):在java.lang.reflect.Method.invokeNative(本机方法) 09-10 18:44:32.475:错误/数据库(415):在java.lang.reflect.Method.invoke(Method.java:521) 09-10 18:44:32.475:错误/数据库(415):在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 09-10 18:44:32.475:错误/数据库(415):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 09-10 18:44:32.475:错误/数据库(415):在dalvik.system.NativeStart.main(本机方法)

I have a list view populated by an adapter reading from SQLite database. When I scroll down in the list on screen I get the following error. I also get the same error when switching to another tab in the application (it is a tab based app).

close() was never explicitly called on database
DatabaseNotClosedException : Application did not close the cursor or database object that was opened here.

Does anyone know why this is happening ? I have posted the main and adapter class files below.

Main Class :

public class Home extends ListActivity {

private DataBaseHelper myDbHelper;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.homeaz);

    ListView yourList = (ListView) findViewById(android.R.id.list);

    yourList.setOnItemClickListener(new OnItemClickListener()

    {
                    @Override
                    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

                        Log.e("onClick",""+arg3);
                        Intent i = new Intent(Home.this,DetailView.class);
                        i.putExtra(DataBaseHelper.ID, arg3);
                        // Activity returns an result if called with startActivityForResult

                        /**Home.this.finish();*/
                        startActivity(i);

                        }   
    });


    myDbHelper = new DataBaseHelper(this);

    try {

        myDbHelper.createDataBase();

} catch (IOException ioe) {

    throw new Error("Unable to create database");

}

try {

    myDbHelper.openDataBase();

}catch(SQLException sqle){

    throw sqle;

}

try {

    Cursor cursor = getPlaces();
    showPlaces(cursor);

}

finally {

myDbHelper.close();

}
}

private static String ORDER_BY = NAME + " ASC";

private Cursor getPlaces() {

    SQLiteDatabase db = myDbHelper.getReadableDatabase();
    Cursor cursor = db.query(TABLE_NAME, null, null, null, null, null, ORDER_BY);
    startManagingCursor(cursor);
    return cursor;

}

private void showPlaces(Cursor cursor) {

    MyCustomAdapterClass adapter = new MyCustomAdapterClass(this,cursor, true); setListAdapter(adapter); 

}

Adapter Class :

public class MyCustomAdapterClass extends CursorAdapter {

public MyCustomAdapterClass(Context context, Cursor c, boolean autoRequery) {
    super(context, c, autoRequery);
    // TODO Auto-generated constructor stub
}

@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return LayoutInflater.from(context).inflate(R.layout.item, parent, false);
}

@Override

public void bindView(View view, Context context, Cursor cursor) {
((TextView) view.findViewById(R.id.name)).setText(cursor.getString(cursor.getColumnIndex("Name")));
((TextView) view.findViewById(R.id.description)).setText(cursor.getString(cursor.getColumnIndex("Area")));
((TextView) view.findViewById(R.id.address)).setText(cursor.getString(cursor.getColumnIndex("AddressLine1")));
switch (cursor.getInt(cursor.getColumnIndex("_id"))) {
case 1:
((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture1);
break;
case 2:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture2);
break;
case 3:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture3);
break;
case 4:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture4);
break;
case 5:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture5);
break;
case 6:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture6);
break;
case 7:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture7);
break;
case 8:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture8);
break;
case 9:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture9);
break;
case 10:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture10);
break;
case 11:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture11);
break;
case 12:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture12);
break;
case 13:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture13);
break;
case 14:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture14);
break;
case 15:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture15);
break;
case 16:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture16);
break;
case 17:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture17);
break;
case 18:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture18);
break;
case 19:
    ((ImageView) view.findViewById(R.id.Logo)).setImageResource(R.drawable.picture19);
break;
case 20:

Log :

09-10 18:44:25.495: INFO/ActivityManager(59): Starting activity: Intent { cmp=com.Beutelkind.Database/.DetailView (has extras) }
09-10 18:44:25.665: DEBUG/dalvikvm(415): GC_EXTERNAL_ALLOC freed 4966 objects / 284992 bytes in 66ms
09-10 18:44:26.284: DEBUG/dalvikvm(415): GC_EXTERNAL_ALLOC freed 300 objects / 14840 bytes in 56ms
09-10 18:44:27.435: INFO/ActivityManager(59): Displayed activity com.Beutelkind.Database/.DetailView: 1888 ms (total 1888 ms)
09-10 18:44:28.725: INFO/ActivityManager(59): Starting activity: Intent { cmp=com.Beutelkind.Database/.Main }
09-10 18:44:28.825: INFO/Database(415): sqlite returned: error code = 14, msg = cannot open file at source line 25467
09-10 18:44:28.825: ERROR/Database(415): sqlite3_open_v2("/mnt/sdcard/DatabaseC.sqlite", &handle, 1, NULL) failed
09-10 18:44:29.535: INFO/ActivityManager(59): Displayed activity com.Beutelkind.Database/.Main: 781 ms (total 781 ms)
09-10 18:44:32.405: DEBUG/dalvikvm(415): GC_EXTERNAL_ALLOC freed 2748 objects / 167024 bytes in 63ms
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): Releasing statement in a finalizer. Please ensure that you explicitly call close() on your cursor: SELECT DISTINCT _id, Name, Description, Area, Postcode, AddressLine1, OpeningTimes, NearestTube, Cos
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): at android.database.sqlite.SQLiteCompiledSql.(SQLiteCompiledSql.java:62)
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:80)
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): at android.database.sqlite.SQLiteQuery.(SQLiteQuery.java:46)
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345)
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1229)
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1184)
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): at com.Beutelkind.Database.DetailView.populateFields(DetailView.java:79)
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): at com.Beutelkind.Database.DetailView.onCreate(DetailView.java:70)
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): at android.os.Handler.dispatchMessage(Handler.java:99)
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): at android.os.Looper.loop(Looper.java:123)
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): at android.app.ActivityThread.main(ActivityThread.java:4627)
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): at java.lang.reflect.Method.invokeNative(Native Method)
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): at java.lang.reflect.Method.invoke(Method.java:521)
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-10 18:44:32.455: WARN/SQLiteCompiledSql(415): at dalvik.system.NativeStart.main(Native Method)
09-10 18:44:32.475: ERROR/Database(415): close() was never explicitly called on database '/data/data/com.Beutelkind.Database/databases/DatabaseC.sqlite'
09-10 18:44:32.475: ERROR/Database(415): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
09-10 18:44:32.475: ERROR/Database(415): at android.database.sqlite.SQLiteDatabase.(SQLiteDatabase.java:1810)
09-10 18:44:32.475: ERROR/Database(415): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:817)
09-10 18:44:32.475: ERROR/Database(415): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:851)
09-10 18:44:32.475: ERROR/Database(415): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:844)
09-10 18:44:32.475: ERROR/Database(415): at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:540)
09-10 18:44:32.475: ERROR/Database(415): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203)
09-10 18:44:32.475: ERROR/Database(415): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:98)
09-10 18:44:32.475: ERROR/Database(415): at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:158)
09-10 18:44:32.475: ERROR/Database(415): at com.Beutelkind.Database.DetailView.populateFields(DetailView.java:77)
09-10 18:44:32.475: ERROR/Database(415): at com.Beutelkind.Database.DetailView.onCreate(DetailView.java:70)
09-10 18:44:32.475: ERROR/Database(415): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-10 18:44:32.475: ERROR/Database(415): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
09-10 18:44:32.475: ERROR/Database(415): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-10 18:44:32.475: ERROR/Database(415): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-10 18:44:32.475: ERROR/Database(415): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-10 18:44:32.475: ERROR/Database(415): at android.os.Handler.dispatchMessage(Handler.java:99)
09-10 18:44:32.475: ERROR/Database(415): at android.os.Looper.loop(Looper.java:123)
09-10 18:44:32.475: ERROR/Database(415): at android.app.ActivityThread.main(ActivityThread.java:4627)
09-10 18:44:32.475: ERROR/Database(415): at java.lang.reflect.Method.invokeNative(Native Method)
09-10 18:44:32.475: ERROR/Database(415): at java.lang.reflect.Method.invoke(Method.java:521)
09-10 18:44:32.475: ERROR/Database(415): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-10 18:44:32.475: ERROR/Database(415): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-10 18:44:32.475: ERROR/Database(415): at dalvik.system.NativeStart.main(Native Method)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

热情消退2024-12-11 10:45:30

简单一,您没有关闭数据库句柄。例如,您在 getPlaces 中打开一个游标,但在使用完它后永远不会关闭它,也不会关闭它所在的 db 对象。

Easy one, you are not closing your database handles. For instance, you open a cursor in getPlaces but never close it when done using it, nor the db object from where it came.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文