2012-03-19 8 views
0

イム後の行を保持し、doesntのそれsqlite3のは、それを見つけるカント後列を取得しようと、その後、それは私がアプリを殺す場合を除き、すべての罰金とダンディ働く私の設定表の行を保存しようと再起動

Cursor c = db.query(savedSettings.getTableName(), null, null, null, null, null, null); 
    c.moveToLast(); 
    DatabaseUtils.dumpCursor(c); 

    db.setTransactionSuccessful(); 
    db.endTransaction(); 

は、ここで私は私の閉鎖を行う方法は次のとおりです。私はアプリを再起動した後

public void onPause() { 
    db.close(); 
} 

public void onDestroy() { 
    db.close();  
    database.close(); 
} 

public void onStop() { 
    db.close(); 
    database.close(); 
} 

public void onResume() { 
    db = database.getWritableDatabase(); 
} 

それは、その内容を失います。 誰でも何か考えがあります。

答えて

1

アクティビティの再起動後にデータを保持するには、次のコードスニペットを使用してください。

@Override 
    protected void onSaveInstanceState(Bundle outState) 
    { 
     Here you will write to things to bundle which you want to preserve 
      after activity restart. 

     super.onSaveInstanceState(outState); 
    } 

    @Override 
    protected void onRestoreInstanceState(Bundle savedInstanceState) 
    { 
     Here you will restore the values. 
     super.onRestoreInstanceState(savedInstanceState); 
    } 

http://developer.android.com/guide/topics/fundamentals/activities.html#SavingActivityState

・ホープこのヘルプを読んで、あなたの時間を投資してください。

+0

マイデータは、アプリケーションの1つのインスタンスのライフサイクルより長く持続する必要があります。しかし、thx –

関連する問題

 関連する問題