I am using the following code to write a text file to the SD card:
File sdRoot = null;
File dataFile = null;
sdRoot = Environment.getExternalStorageDirectory();
dataFile = new File(sdRoot, "myFile.txt");
fWriter = new FileWriter(dataFile, true);
fWriter.write("data as string");
This works fine in the emulator, and writes the file to the top level of the SD card.
However on a device, this puts the file into the main device storage,not the SDD card. Any clues about why this happens? I have tried two tablets, a Huawei Ideos and an MID X5A. The SD card in general works fine in both devices - I can download files onto the card and access them with File Explorer. I am looking for generic code, rather then specifying a literal path, as I want the code to work on any device with external storage.
I'm also having problems with the file on the Huawei. The file is written to the top level of the device storage, I can read it from the application and also with File Explorer, but when I connect up via USB, my computer can't see this file. It sees everything else. I need to be able to upload the data file. Help appreciated.