2013-11-23 39 views
2

如何存儲和檢索我的應用程序的私人應用程序數據?我有一個根據用戶輸入的特定參數(文件路徑,卷等)運行的活動,我希望能夠存儲他們輸入的內容,然後在他們每次打開活動時檢索它。Android商店和檢索數據

我應該用戶FileWrite還是FileOutputStream/FileInputStream?


更新: 目前我有這個作爲保存字符串的代碼。

final String audioPathFN = "Audio_Path"; 
final String audioPathC = String.valueOf(path); 
FileOutputStream saveAudioPath; 
try { 
    saveAudioPath = openFileOutput(audioPathFN, Context.MODE_PRIVATE); 
    saveAudioPath.write(audioPathC.getBytes()); 
    saveAudioPath.close(); 
} catch (Exception e) { 
    e.printStackTrace(); 
} 

現在如何檢索字符串,以便我可以在應用程序中使用它?

+0

以下是您的選項:http://developer.android.com/guide/topics/data/data-storage.html –

回答