由网友(泪的方程式)分享简介:任何人都可以请让我清醒有关共享preferences的Android系统。我如何可以设置显示警报消息只有一次,当活动被初始加载的应用程序的条件?Can anybody please clear me about the SharedPreferences in Android.How can I set a...
任何人都可以请让我清醒有关共享preferences的Android系统。 我如何可以设置显示警报消息只有一次,当活动被初始加载的应用程序的条件?
Can anybody please clear me about the SharedPreferences in Android. How can I set a condition of displaying a "Alert Message" only once when the Activity gets loaded initially in the Application?
它是如何通过使用共享preferences做?
How it is done by using SharedPreferences?
Thsnks, 约翰·
Thsnks, John
推荐答案
这是完全巧合,我发誓,我的博客上讲述这个:)
It's completely by coincidence, I swear, that I blogged about this today :)
SharedPreferences settings = this.getSharedPreferences("MyApp",0);
boolean firstrun=settings.getBoolean("firstrun",true);
if (firstrun) {
SharedPreferences.Editor e = settings.edit();
e.putBoolean("firstrun",false);
e.commit();
// Do something here that you only want to happen the first time
}
相关推荐
最新文章