How can I let users access the internal storage directory of my app?

I took a closer look at the result of getFilesDir() vs getExternalFilesDir() and found that getFilesDir() returns /data/data/[packagename]/files while getExternalFilesDir() returns /Android/data/[packagename]/files. I thought the app files I was browsing in /Android/data were the internal storage directories, but now I see that those are actually the external storage directories. If the internal storage directories are … Read more

Get file name from FileOutputStream

Looks like the answer is no: http://download.oracle.com/javase/1.4.2/docs/api/java/io/FileOutputStream.html http://docs.oracle.com/javase/7/docs/api/index.html?java/io/FileOutputStream.html There are no public methods that return the File or String used in construction of the stream. EDIT: The same holds for FileInputStream.

Java FileOutputStream Create File if not exists

It will throw a FileNotFoundException if the file doesn’t exist and cannot be created (doc), but it will create it if it can. To be sure you probably should first test that the file exists before you create the FileOutputStream (and create with createNewFile() if it doesn’t): File yourFile = new File(“score.txt”); yourFile.createNewFile(); // if … Read more

Android Error – Open Failed ENOENT

With sdk, you can’t write to the root of internal storage. This cause your error. Edit : Based on your code, to use internal storage with sdk: final File dir = new File(context.getFilesDir() + “/nfs/guille/groce/users/nicholsk/workspace3/SQLTest”); dir.mkdirs(); //create folders where write files final File file = new File(dir, “BlockForTest.txt”);

file.delete() returns false even though file.exists(), file.canRead(), file.canWrite(), file.canExecute() all return true

Another bug in Java. I seldom find them, only my second in my 10 year career. This is my solution, as others have mentioned. I have nether used System.gc(). But here, in my case, it is absolutely crucial. Weird? YES! finally { try { in.close(); in = null; out.flush(); out.close(); out = null; System.gc(); } … Read more