Possible Duplicate:
Array of strings in SharedPreferences
I am a new one in Android and would like to study how to save and retrive String[] from Preferences.For now I have two samples of code. This one for saving
void saveText() {
sPref = getSharedPreferences("MyPref", MODE_PRIVATE);
Editor ed = sPref.edit();
ed.putString(SAVED_TEXT, position_name);
ed.commit();
}
and position_name came as an EditText input. First, it should be saved in a String array and then String array saved in Preferences. For loading I have the following code
void loadText() {
sPref = getSharedPreferences("MyPref", MODE_PRIVATE);
String position_name = sPref.getString(SAVED_TEXT, "");
bazar.add(new Bazar(position_name, R.drawable.unread));
}
both methods are static but I want them to work with dynamic String type data. In short I type some data it should be stored in String array then String array stored in Preferences and when I load my activity I want those stored datas to be retrieved. Tried different approaches no result. Can you help me on this.