简体   繁体   English

Android-从SDCard删除数据

[英]Android - Remove data from SDCard

My application use the SDCard to store data (about 100 Mb of stuff). 我的应用程序使用SDCard存储数据(大约100 Mb的东西)。 I would like to delete these file when the application is deleted through the application manager and offer a way to clear the data from there (like the Google Apps does). 当通过应用程序管理器删除应用程序时,我想删除这些文件,并提供一种从那里清除数据的方法(就像Google Apps一样)。 Any ideas ? 有任何想法吗 ?

Quote From http://developer.android.com/guide/topics/data/data-storage.html 引用http://developer.android.com/guide/topics/data/data-storage.html

Accessing files on external storage 访问外部存储上的文件

If you're using API Level 8 or greater, use getExternalFilesDir() to open a File that represents the external storage directory where you should save your files. 如果您使用的是API Level 8或更高版本,请使用getExternalFilesDir()打开一个文件,该文件表示应该在其中保存文件的外部存储目录。 ... If the user uninstalls your application, this directory and all its contents will be deleted. ... 如果用户卸载您的应用程序,则该目录及其所有内容将被删除。

From my understanding this will create a file on the sd card which has a scope (like a directory of your applications package namespace) and the phone will delete the directory when you uninstall the app. 据我了解,这将在sd卡上创建一个具有范围的文件(例如您的应用程序程序包名称空间的目录),并且在您卸载应用程序时手机会删除该目录。 I assume this is how Google apps achieves this function. 我认为这是Google应用实现此功能的方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM