Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileWriter; import java.io.IOException; public class Main { public static Boolean canWrite(File f) { if (f.isDirectory()) { FileWriter w = null; String testFilename = f.getPath() + "/.EASYRPG_WRITE_TEST"; try { w = new FileWriter(testFilename); // Permissions are checked on open, but it is Android, better be save w.write("Android >.<"); } catch (IOException e) { return false; } finally { try { if (w != null) { w.close(); } } catch (IOException e) { } } File testFile = new File(testFilename); if (testFile.exists()) { // Does not throw testFile.delete(); } } else { boolean deleteAfter = f.exists(); try { FileWriter w = new FileWriter(f, true); w.close(); } catch (IOException e) { return false; } if (deleteAfter) { f.delete(); } } return true; } }