If I run the following code on an ASUS Transformer then 'testfile.txt' is created in the top level of the 'sd card' directory as expected.
private void testWriteFile () throws IOException
{
File sdCard = Environment.getExternalStorageDirectory();
File file = new File(sdCard, "testfile.txt");
FileOutputStream myOutput = new FileOutputStream(file);
byte buffer[] = {'0','1','2','3','4','5','6','7','8','9'};
myOutput.write(buffer,0,buffer.length);
myOutput.flush();
myOutput.close();
}
I can view the file on the ASUS Transformer using a File Manager app. I can see the file from a Windows dos box via the 'adb shell' command and its permissions appear to be set correctly. However, if I view the directory from Windows Explorer, 'testfile.txt' is not there. I have set the options to display hidden and system files, but with no luck.
If I use the ASUS file manager app to change the name of 'testfile.txt', then it becomes visible in Windows Explorer, so other apps are able to make files visible in Explorer.
If I run the same code on a ZTE Blade (Orange San Francisco) then I can see 'testfile.txt' in Windows Explorer without needing to change its name.
Is there something else I need to do to finalize this file so that it becomes visible?
A similar problem is reported here, Can't see a file in Windows written by an android app on sd-card unless I "Force Close" the app, but forcing a close in my case does not make the file visible.