Reputation: 334
How do I store and retrieve private application data for my app? I have an activity that runs depending on certain parameters entered by the user (file path, volume, etc.) and I want to be able to store what they input and then retrieve it every time they open the activity.
Should I user FileWrite or FileOutputStream/FileInputStream?
UPDATE: Currently I have this as the code for saving the string.
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();
}
Now how do I retrieve the string so I can use it in the app?
Upvotes: 2
Views: 963
Reputation: 38168
There are a few mechanisms to store private data :
activity.getCacheDir()
folderAll those options are explained here : http://developer.android.com/training/basics/data-storage/index.html
Of course, all those solutions are local, you can also wanna use a web-service to communicate data with a server, but you would then be entering in a totally different landscape.
Upvotes: 1