Write a text file to SD card   Write a text file to SD card
Postby kognos » Thu Sep 01, 2011 10:00 am  I am using the
following code to write a text file to the SD card:  File sdRoot
= null; File dataFile = null; FileWriter fWriter; try { sdRoot =
Environment.getExternalStorageDirectory(); dataFile = new
File(sdRoot, "myFile.txt"); fWriter = new FileWriter(dataFile,
true); fWriter.write("data as string"); catch ...  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