I have made an application. It\'s a button that shows the time you have pressed it. Every time I \"kill\" the application, the timer starts at 0 again (naturally). How can I mak
Setting values in Preference:
SharedPreferences.Editor editor = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE).edit();
editor.putString("name", "slama");
editor.putInt("idName", 28);
editor.commit();
Retrieve data from preference:
// MY_PREFS_NAME - a static String variable like:
//public static final String MY_PREFS_NAME = "MyPrefsFile";
SharedPreferences prefs = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE);
String restoredText = prefs.getString("text", null);
if (restoredText != null) {
String name = prefs.getString("name", "No name defined");//"No name defined" is the default value. String name = prefs.getString("name", "");
int idName = prefs.getInt("idName", 0); //0 is the default value.
}
and this is an Android Shared Preferences Tutorial: http://www.tutorialspoint.com/android/android_shared_preferences.htm
it can help you to solve your problem