Click here to Skip to main content
15,882,152 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to delete the files from external storage using java code in android?
Posted

Hello Suma,

Make sure the manifest file for your app contains following permission entries then you can use the code given below to delete a file from external storage.
XML
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Code for Deletion
Java
File file = new File(YOUR_FILE_PATH);
boolean isSuccess = file.delete();

Regards,
 
Share this answer
 
Comments
_Amy 4-Jun-13 4:18am    
+5! I just added few links which will explain about storage option in Android. Please see the solution below.
Maciej Los 4-Jun-13 5:09am    
Agree! +5
Prasad Khandekar 4-Jun-13 5:27am    
Thank's Maciej.
I agree with Prasad in Solution 1[^]. I am adding few links which will explain you about storage option in android.
Storage Options[^]
Android Environment[^]


--Amit
 
Share this answer
 
Comments
Maciej Los 4-Jun-13 5:09am    
+5!
_Amy 4-Jun-13 5:10am    
Thanks Maciej. ;)
Prasad Khandekar 4-Jun-13 5:28am    
Thank's Amy for providing additional info. +5.
_Amy 4-Jun-13 5:30am    
Thank You Prasad. :)
suma from bangalore 4-Jun-13 5:59am    
Thank you Prasad:-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900