Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Preserve or delete files created by the application on uninstall

I created an application which creates and stores files to sdcard. Is there a way to bind the folder with application in order to delete all files when the user runs uninstall on android device?

like image 895
Niko Gamulin Avatar asked Aug 03 '09 13:08

Niko Gamulin


People also ask

Does uninstalling Android app delete data?

App data and cache is deleted. But any folders/files the app makes in your storage directory will not be removed. Right, and the data in your storage directory will not be deleted when you delete the app data manually.

How do I get rid of leftover files after uninstalling software?

Type "%appdata%" into the search box and delete all related files. After deleting all the files, the software is totally removed on your computer. To ensure prompt and through uninstall of a software, you can also use a third-party uninstaller to help.

Does uninstalling an app remove all files?

DIY uninstall Android apps You may be doing it wrong. That should get rid of most of the files, folders and caches created by the app and then remove the app itself. However, this is not guaranteed to remove every trace of an app and there might still be files lurking around in the phone's storage.


1 Answers

Seems like there have been some developments since 2009 :).

From the documentation:

If you're using API Level 8 or greater, use getExternalCacheDir() to open a File that represents the external storage directory where you should save cache files. If the user uninstalls your application, these files will be automatically deleted. However, during the life of your application, you should manage these cache files and remove those that aren't needed in order to preserve file space.

If you're using API Level 7 or lower, use getExternalStorageDirectory() to open a File that represents the root of the external storage, then write your cache data in the following directory:

/Android/data//cache/ The is your Java-style package name, such as "com.example.android.app".

like image 165
rony l Avatar answered Oct 15 '22 10:10

rony l