Reputation: 42854
Environment.getExternalStorageDirectory()
Environment.getExternalStorageDirectory()
locationHow to do this
Note: It must not delete other files created by other application
Upvotes: 3
Views: 1170
Reputation: 1007554
Use the delete()
method on the File
object for each file to be deleted.
You will need to determine for yourself what files are to be deleted. Nobody else will know, including Android. There is no app-specific ownership information on files on external storage, even if such data would necessarily be reliable for your use case.
Also, bear in mind that each account on Android gets its own part of external storage, and you can only delete files that are in the external storage for whatever account it is that is presently running. Other accounts (on Android 4.2+ tablets and Android 5.0+ phones) are not accessible to you.
Upvotes: 2