如何删除共享preference而在Android的应用程序卸载 [英] how to remove shared preference while application uninstall in android
问题描述
我有一个Android应用程序保存的登录信息,如用户名和密码通过共享preferences
这就是工作正常,但我需要删除所有我所用共享preferences
,而我的应用程序卸载。怎么办呢?
I have an android application to save the login details such as user name and password via SharedPreferences
thats works fine, but i need to remove all my used SharedPreferences
while my application uninstall. How to do it?
SavePreferences("one ", "");
SavePreferences("two", "");
LoadPreferences();
private void SavePreferences(String key, String value){
sharedPreferences = getSharedPreferences("TEST", MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(key, value);
editor.commit();
}
private void LoadPreferences(){
sharedPreferences = getSharedPreferences("TEST", MODE_PRIVATE);
String strSavedMem1 = sharedPreferences.getString("MEM1", "");
String strSavedMem2 = sharedPreferences.getString("MEM2", "");
}
我想删除这个共享preferences
时,我的应用程序卸载。
I want to remove this SharedPreferences
when my application uninstall.
推荐答案
共享preferences
总是伴随着应用程序卸载删除。
SharedPreferences
is always deleted along with the app uninstall.
在卸载所有的应用程序都在内存中进行的更改被撤销的任何应用程序,这意味着你的共享preference文件,其他数据文件,数据库文件,应用程序就会自动由Android操作系统中删除。
When you uninstall any application all the changes the application have made in your internal memory are revoked, that means your SharedPreference files, Other data files, Database file, Application gets removed automatically by the Android OS.
这篇关于如何删除共享preference而在Android的应用程序卸载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!