Reputation: 755
i need to store a variable in phone memory, and later get that variable to show it.
Please, give me some information or anything to search. Thanks
Upvotes: 6
Views: 6967
Reputation: 755
The final result.
SharedPreferences app_preferences = PreferenceManager.getDefaultSharedPreferences(this);
String text = app_preferences.getString("name", "default");
...
SharedPreferences.Editor editor = app_preferences.edit();
editor.putString("name",name.getText().toString());
editor.commit();
Upvotes: 1
Reputation: 11227
static SharedPreferences settings;
static SharedPreferences.Editor editor;
settings = this.getPreferences(MODE_WORLD_WRITEABLE);
editor = settings.edit();
editor.putString("Variablenname_1", "1");
editor.commit();
if you want so get the value use:
String val = settings.getString("Variablenname_1", "0");
Upvotes: 6
Reputation: 5900
I think Shared Preferences is a good idea for you, read this for more information: http://developer.android.com/guide/topics/data/data-storage.html
Upvotes: 2