Check File

This is how you can check if a pesific fil exists on your sdcard, this will all so work for you system directory but not the data derectory as that an only be read with super user permissions(also cant be read by an api).

boolean exists1 = (new File(Environment.getExternalStorageDirectory() + “/example/1”)).exists();

if (exists1) {


Alternatively this methord 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


Posted in Java. 3 Comments »

3 Responses to “Check File”

  1. games for kids Says:

    That’s pretty exciting news and I really hope more people get to read this.

  2. solid state drive Says:

    It was a very nice idea! Just wanna say thank you for the information you have diffused. Just continue composing this kind of post. I will be a loyal reader, thanks a lot.

  3. Says:

    Awesome piece of writing..

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: