开发者

How can I create cookies or sessions in android platform?

开发者 https://www.devze.com 2022-12-12 19:43 出处:网络
How can I create cookies or sessions in android platform? I am using one application like preferences settings. 开发者_StackOverflow社区when I change the theme of android application need to store so

How can I create cookies or sessions in android platform?

I am using one application like preferences settings. 开发者_StackOverflow社区when I change the theme of android application need to store somewhere(?) the last updated theme name.

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号