清除AppData后Android崩溃

时间:2014-03-13 15:13:14

标签: android android-sqlite android-preferences

我正在清除我的应用内容,作为退出流程的一部分,如下所述:

How to Clear Data on Android Programmatically

一切正常,应用程序已关闭,但在我尝试重新登录应用程序崩溃后,由于DB中的一些插入语句。在这次崩溃后我重试,一切正常......这是我的logcat:

03-13 17:04:35.620  20630-20630/ro.gebs.askur E/SQLiteLog﹕ (1802) os_unix.c:30026: (2) stat(/data/data/ro.gebs.askur/databases/askurmsgs.db) -
03-13 17:04:35.620  20630-20630/ro.gebs.askur E/SQLiteLog﹕ (1802) statement aborts at 11: [INSERT INTO team(joinedDate,name) VALUES (?,?)]
03-13 17:04:35.620  20630-20630/ro.gebs.askur E/SQLiteLog﹕ (1) statement aborts at 2: [ROLLBACK;] cannot rollback - no transaction is active
03-13 17:04:35.620  20630-20630/ro.gebs.askur D/AndroidRuntime﹕ Shutting down VM
03-13 17:04:35.620  20630-20630/ro.gebs.askur W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x415a0ba8)
03-13 17:04:35.620  20630-20630/ro.gebs.askur E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: ro.gebs.askur, PID: 20630
    android.database.sqlite.SQLiteException: cannot rollback - no transaction is active (code 1)
            at android.database.sqlite.SQLiteConnection.nativeExecute(Native Method)
            at android.database.sqlite.SQLiteConnection.execute(SQLiteConnection.java:555)
            at android.database.sqlite.SQLiteSession.endTransactionUnchecked(SQLiteSession.java:439)
            at android.database.sqlite.SQLiteSession.endTransaction(SQLiteSession.java:401)
            at android.database.sqlite.SQLiteDatabase.endTransaction(SQLiteDatabase.java:522)
            at ro.gebs.askur.provider.AskurProvider.applyBatch(AskurProvider.java:210)
            at android.content.ContentProvider$Transport.applyBatch(ContentProvider.java:260)
            at android.content.ContentProviderClient.applyBatch(ContentProviderClient.java:377)
            at android.content.ContentResolver.applyBatch(ContentResolver.java:1227)
            at ro.gebs.askur.provider.DatabaseHelper.addTeam(DatabaseHelper.java:52)
            at ro.gebs.askur.ui.fragments.LoginFragment.insertDummyData(LoginFragment.java:54)
            at ro.gebs.askur.ui.fragments.LoginFragment.access$000(LoginFragment.java:26)
            at ro.gebs.askur.ui.fragments.LoginFragment$1.onClick(LoginFragment.java:40)
            at android.view.View.performClick(View.java:4438)
            at android.view.View$PerformClick.run(View.java:18422)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5017)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
            at dalvik.system.NativeStart.main(Native Method)

这里我称之为清晰内容方法:

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    switch (item.getItemId()) {
        case R.id.action_settings:
            break;
        case R.id.action_team:
            Intent intent = new Intent(this, JoinTeamActivity.class);
            startActivity(intent);
            break;
        case R.id.action_logout:
            AskurApp.getInstance().clearApplicationData();
            SharedPreferences prefs = getSharedPreferences(Constants.PREFS_NAME, MODE_PRIVATE);
            prefs.edit().clear().commit();
            finish();
            break;
    }
    return true;
}

关于我可能做错什么的任何想法?

0 个答案:

没有答案