0
ContextWrapper cw = new ContextWrapper(getApplicationContext());
File myFile = cw.getDir("mydata", Context.MODE_PRIVATE);

Now please tell me how to remove whatever contains(mainly images) myFile(folder), how to clear it?

braX
  • 11,506
  • 5
  • 20
  • 33
  • Check here.. http://stackoverflow.com/questions/6994518/how-to-delete-the-content-of-text-file-without-deleting-itself – Ranjit Jun 30 '14 at 09:44
  • What do you mean by 'Clear'? Do you mean Deleting files itself or just deleting data from it? – Paresh Mayani Jun 30 '14 at 12:47

2 Answers2

1
PrintWriter pw = new PrintWriter("fileName.txt");
pw.close();

OR

new RandomAccessFile(fileName).setLength(0);
Aniruddha
  • 4,477
  • 2
  • 21
  • 39
0

Easiest way to clear a folder is by recursion:

void deleteDirContent(File file) {
    if (file.isDirectory()) {
        for (File child : file.listFiles())
            deleteDirContent(child); <--------
    }
    file.delete();
}
Gilad Haimov
  • 5,767
  • 2
  • 26
  • 30