Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete internal storage file in android?

I have used the Android internal storage to save a file for my application (using openFileOutput) but I would like to delete that file, is it possible and how?

like image 476
maxsap Avatar asked Aug 24 '10 08:08

maxsap


People also ask

How do I delete internal storage on my phone?

Clear cache memory Most of the memory of the phone goes to the cache, so first, clear it. Go to settings and go to storage. Here you will see the cache. Clear it.

Where is internal storage file on Android?

But in most cases, you can see the internal storage of an Android phone: Navigate to My Files to view internal storage as well as SD card and Network storage. Here, tap Internal Storage to see your files and folders. Tap the DCIM folder to view your photos.


2 Answers

File dir = getFilesDir(); File file = new File(dir, "my_filename"); boolean deleted = file.delete(); 
like image 72
plugmind Avatar answered Oct 12 '22 00:10

plugmind


I know this is a bit of an oldie, but the docs say to use:

deleteFile("filename"); 

rather than:

File.delete(); 

Which if you are already using:

getFilesDir(); 

kind of makes sense.

like image 41
Barry Avatar answered Oct 12 '22 00:10

Barry