How could you delete a directory containing files on android assets directory.
You cannot delete (or modify) assets at runtime. They are read-only.
Question
How could you delete a directory containing files on android assets directory.
I tried doing this but does not work.
try {
listaAssets = getAssets().list("");
} catch (IOException e) {
e.printStackTrace();
}
for(String s : listaAssets){
deleteFolder(s)
}
public void deleteFolder(String path){
File folder = new File(path);
File [] list;
int num =0;
boolean del = false;
try{
list = folder.listFiles();
num = list.length;
for (int i = 0; i<num; i++){
list[i].delete();
}
if(folder.delete()){
del = true;
}else{
del = false;
}
}catch(Exception e){
Log.e("ERROR","Error: "+e.getMessage());
}
}
Error: null
La solution
How could you delete a directory containing files on android assets directory.
You cannot delete (or modify) assets at runtime. They are read-only.