Android read/write permission of a folder

Manoj picture Manoj · Feb 10, 2013 · Viewed 26k times · Source

I am doing a new android app. I want to create a folder in "Android" folder which is available in sdcard. Before that I want to check whether the folder has read/write permission. How can I get that? can anyone help me to do this.

Answer

poitroae picture poitroae · Feb 10, 2013

You do it the old-school java way. Create a file object and call canWrite() and canRead().

File f = new File("path/to/dir/or/file");
if(f.canWrite()) {
    // hell yeah :)
}