Reputation: 13329
Im checking if a file excists in a directory. If not it should download it.
File file = new File(mediadir, _name);
if(file.exists()) {
Log.i("FILE EXISTS", _name);
} else {
Log.i("DOWNLOAD", _name);
new Download().execute(context, name, "http://192.168.2.136:8080/rest/transfer/"+ linkid +"/"+ username +"/" + json_data.getString("ID"));
}
But file.exists() is always true
the file does not exists on there
I run this right before the file.exists()
File mediadir = getDir("tvr", Context.MODE_PRIVATE);
if (mediadir.isDirectory()) {
String[] children = mediadir.list();
for (int i = 0; i < children.length; i++) {
new File(mediadir, children[i]).delete();
}
}
Upvotes: 0
Views: 1594
Reputation: 3261
Try this,
for (File f : myDir.listFiles()) {
//Do your stuf
String name = f.getName();
//Here you will get file you have already stored in directory.
}
Upvotes: 0