Reputation: 6162
I have saved some ser file by below code
OutputStream file = context.openFileOutput(fileName, Context.MODE_PRIVATE);
BufferedOutputStream buffer = new BufferedOutputStream( file );
ObjectOutput output = new ObjectOutputStream(buffer);
try{
output.writeObject(map1);
}
Now please tell me how to delete all files saved through this code.
Upvotes: 0
Views: 534
Reputation: 67296
You can do it like this, Get the Path of folder that you want to delete with all files and then delete all files one by one.
File dir = new File("/data/directory_name/");
if (dir.isDirectory()) {
String[] children = dir.list();
for (int i = 0; i < children.length; i++) {
new File(dir, children[i]).delete();
}
}
Upvotes: 3
Reputation: 1427
try this code
File file = new File(Environment.getExternalStorageDirectory()+"/filenameWithExtenstion");
file.delete();
Upvotes: 1