Tuesday, February 7, 2012

Android Tutorial - Check File

This is how you check for a specific file on your SDCARD.
boolean exists1 = (new File(Environment.getExternalStorageDirectory() + “/example/1″)).exists();
if (exists1) {
This method can be used to create a new folder or delete files/directorys
File a = new File(Environment.getExternalStorageDirectory() + “/example1/example2″);
a.mkdir();//this will create example2 only
a.mkdirs();//this will create example1 and example2
a.delete();//this will delete example2 weather it is a file or a folder

No comments:

Post a Comment