由于Android的未定型语句而无法关闭

由于Android的未定型语句而无法关闭,第1张

概述我希望有人可以帮助我解决这个问题.我无法重现此错误,但收到了大量的崩溃报告.下面是堆栈跟踪和相关代码.我想添加“cursor.close();”会解决问题,但事实并非如此.任何人都可以弄清楚发生了什么事吗?第187行是mDbAdapter.close(); java.lang.RuntimeException: Unable to start activity ComponentInfo{com. 我希望有人可以帮助我解决这个问题.我无法重现此错误,但收到了大量的崩溃报告.下面是堆栈跟踪和相关代码.我想添加“cursor.close();”会解决问题,但事实并非如此.任何人都可以弄清楚发生了什么事吗?第187行是mDbAdapter.close();

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.companionfree.WLthemeVIEwer/com.companionfree.WLthemeVIEwer.VIEwer}: androID.database.sqlite.sqliteException: unable to close due to unfinalised statementsat androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:2753)at androID.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2769)at androID.app.ActivityThread.access00(ActivityThread.java:129)at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:2117)at androID.os.Handler.dispatchMessage(Handler.java:99)at androID.os.Looper.loop(Looper.java:143)at androID.app.ActivityThread.main(ActivityThread.java:4717)at java.lang.reflect.Method.invokeNative(Native Method)at java.lang.reflect.Method.invoke(Method.java:521)at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:626)at dalvik.system.NativeStart.main(Native Method)Caused by: androID.database.sqlite.sqliteException: unable to close due to unfinalised statementsat androID.database.sqlite.sqliteDatabase.dbclose(Native Method)at androID.database.sqlite.sqliteDatabase.onAllReferencesReleased(sqliteDatabase.java:323)at androID.database.sqlite.sqliteDatabase.close(sqliteDatabase.java:886)at androID.database.sqlite.sqliteOpenHelper.close(sqliteOpenHelper.java:191)at com.companionfree.WLthemeVIEwer.DbAdapter.close(DbAdapter.java:163)at com.companionfree.WLthemeVIEwer.VIEwer.getNavData(VIEwer.java:178)at com.companionfree.WLthemeVIEwer.VIEwer.onCreate(VIEwer.java:65)at androID.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)at androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:2717)... 11 more

资源:

private voID getNavData() {    mDbAdapter.open();    //      mNav = MainActivity.mDbAdapter.getNav(mMode);    //      startManagingCursor(mNav);    Cursor cursor = mDbAdapter.getNav(mMode);    int i=0;    if (!(mMode==MainActivity.MODE_FAVORITE_CREATORS)) {        mNav2 = new int[cursor.getCount()];        while (cursor.movetoNext()) {            String name = cursor.getString(cursor.getColumnIndexOrThrow(DbAdapter.KEY_name));            mNav2[i] = mDbAdapter.getPrimaryRowID(name);            i++;        }    } else {                int[] temp = new int[9999];        while (cursor.movetoNext()) {            String creatorname = cursor.getString(cursor.getColumnIndexOrThrow(DbAdapter.KEY_name));            Cursor creatorthemes = mDbAdapter.getCreatorthemes(creatorname);            while (creatorthemes.movetoNext()) {                String name = creatorthemes.getString(creatorthemes.getColumnIndexOrThrow(DbAdapter.KEY_name));                temp[i] = mDbAdapter.getPrimaryRowID(name);                i++;            } creatorthemes.close();        }        mNav2 = new int[i];        for (int c=0;c<mNav2.length;c++) {            mNav2[c] = temp[c];        }    }    cursor.close();    mDbAdapter.close();}

DbAdapter.java

public voID close() {    mDbHelper.close();}

编辑:我尝试了第一个解决方案并在市场上更新了它.这是最新的崩溃报告:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.companionfree.WLthemeVIEwer/com.companionfree.WLthemeVIEwer.VIEwer}: androID.database.sqlite.sqliteException: unable to close due to unfinalised statementsat androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:2669)at androID.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2685)at androID.app.ActivityThread.access00(ActivityThread.java:126)at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:2038)at androID.os.Handler.dispatchMessage(Handler.java:99)at androID.os.Looper.loop(Looper.java:123)at androID.app.ActivityThread.main(ActivityThread.java:4633)at java.lang.reflect.Method.invokeNative(Native Method)at java.lang.reflect.Method.invoke(Method.java:521)at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:616)at dalvik.system.NativeStart.main(Native Method)Caused by: androID.database.sqlite.sqliteException: unable to close due to unfinalised statementsat androID.database.sqlite.sqliteDatabase.dbclose(Native Method)at androID.database.sqlite.sqliteDatabase.onAllReferencesReleased(sqliteDatabase.java:322)at androID.database.sqlite.sqliteDatabase.close(sqliteDatabase.java:990)at androID.database.sqlite.sqliteOpenHelper.close(sqliteOpenHelper.java:191)at com.companionfree.WLthemeVIEwer.DbAdapter.close(DbAdapter.java:163)at com.companionfree.WLthemeVIEwer.VIEwer.getNavData(VIEwer.java:179)at com.companionfree.WLthemeVIEwer.VIEwer.onCreate(VIEwer.java:65)at androID.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)at androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:2633)... 11 moreAs requested in the comments    public int getPrimaryRowID(String name) {        Cursor cursor =  mDb.query(table_themeS_V2,new String[] {KEY_ROWID,KEY_name},KEY_name + " = '" + name +"'",null,null);        cursor.movetoFirst();        return Integer.parseInt(cursor.getString(cursor.getColumnIndexOrThrow(KEY_ROWID)));    }
解决方法 你在一个循环中创建新游标(creatorthemes)并且从不清理它们中的任何一个 总结

以上是内存溢出为你收集整理的由于Android的未定型语句而无法关闭全部内容,希望文章能够帮你解决由于Android的未定型语句而无法关闭所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1121878.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存