Clear data in android using coding

家住魔仙堡 提交于 2019-12-10 19:38:34

问题


I want to clear data through coding for my application. Right now I am Clearing Data from Settings->Applications->Manage Application->My Application->Clear Data.

But I want to do it through coding. Please help me if any one have answers.


回答1:


Use Context's getFilesDir method to get the directory, and then delete all directory and data as explained here.




回答2:


Using MByD's code to delete a dir, delete the folder /data/app/my.app.name ;-)




回答3:


If the data is "Internal" to the application, it generally can't be cleared from any other app. I did read that you want to clear data of your app through coding but it wasn't clear whether you want to clear data from the same app.

You need to change the same application's code and instruct it to delete the data. But, if you're clearing from the same application you might want to specify which database table or file, for instance, you want to delete instead of just clearing all the data.

You'll find application data here: /data/data/packagename.appname/

Use this to delete the application files: deletefiles()



来源:https://stackoverflow.com/questions/6912541/clear-data-in-android-using-coding

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!