开发者

How can I create cookies or sessions in android platform?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜