簡體   English   中英

Android存儲和檢索數據

[英]Android Store and Retrieve Data

如何存儲和檢索我的應用程序的私人應用程序數據? 我有一個根據用戶輸入的某些參數(文件路徑,卷等)運行的活動,並且我希望能夠存儲他們輸入的內容,然后在每次打開活動時都對其進行檢索。

我應該使用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();
}

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

有幾種存儲私有數據的機制:

所有這些選項均在此處進行了說明: http : //developer.android.com/training/basics/data-storage/index.html

當然,所有這些解決方案都是本地的,您也可以使用Web服務與服務器進行數據通信,但是您將進入一個完全不同的境地。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM