tags:

views:

102

answers:

1

Hi,

How can i create cookies or sessions in android platform?

i am using one application like preferences settings. when ever i change the theme of android application need to store somwhere(?) the last updated theme name.

is there any way to store values cookies in android platform?

Thanks, Jeyavel N

+1  A: 

If you want them to be stored forever, until they're changed, it's SharedPreferences you're after.

SharedPreferences prefs = getSharedPreferences("myPreferenceDatabase", 0);
String mySetting = prefs.getString("savedPropertyName", "defaultValue");

For editing

Editor e = prefs.edit();
e.putString("savedPropertyName", "newValue");
e.commit();

If you just want the item to be stored until the application is closed, you should consider using a global static variable.

David Hedlund
It's working good .Thank you very much.
Jeyavel
i'm glad to hear it. when you receive an answer that you find to be correct, please consider accepting it
David Hedlund