如何防止在设置中清除共享首选项 [英] How to prevent a shared preference from being clear in setting
问题描述
我不想让设置清除任何人的应用程序sharedPreference
:有可能吗?
I don't want to let Settings clear my app sharedPreference
by anyone: is it possible?
推荐答案
嘿,伙计,我发现这里的答案是一种防止从共享首选项中清除数据的方法
hey buddy i found an answer here is a way to prevent data being cleared from Shared Preference
将android:manageSpaceActivity=".ActivityOfMyChoice"
添加到清单的application
标签中,例如:
Add android:manageSpaceActivity=".ActivityOfMyChoice"
to the application
tag of your Manifest like:
<application android:label="MyApp" android:icon="@drawable/icon"
android:manageSpaceActivity=".ActivityOfMyChoice">
然后代替"Clear Data"
,有一个"Manage Space"
按钮启动ActivityOfMyChoice
Then instead of "Clear Data"
, there is a button for "Manage Space"
which launches ActivityOfMyChoice
它将调用我的活动,并且该活动在创建时就完成了:)
it will call my activity and the Activity is finish at creation :)
public class ActivityOfMyChoice extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
finish();
}
}
现在,您可以根据需要任意按管理空间"! :)
Now you can press the "Manage space" as much as you want! :)
此方法在100%的时间内有效.
this method works 100% of the time.
这篇关于如何防止在设置中清除共享首选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!