Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to store variable in phone memory android?

Tags:

android

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

like image 576
fr4n Avatar asked May 20 '11 09:05

fr4n


1 Answers

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");
like image 180
2red13 Avatar answered Sep 21 '22 10:09

2red13