With the following code, I am trying to write to my SD card:
public void writedata(String data) { //BufferedWriter out = null; System.out.println(data); try{ FileOutputStream out = new FileOutputStream(new File("/sdcard/tsxt.txt")); out.write(data.getBytes()); out.close(); } catch (Exception e) { //fehlende Permission oder sd an pc gemountet} System.out.println("CCCCCCCCCCCCCCCCCCCCCCCALSKDJLAK"); } }
Resolution in manifest:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
But now, when I open the file, there is nothing. Where is the problem? I am sure that data has some meaning.
EDIT:
I get this message in LogCat:
02-06 01:59:51.676: W/System.err(1197): java.io.FileNotFoundException: /storage/sdcard0/sdcard/tsxt.txt: open failed: ENOENT (No such file or directory)
I tried to create the file on the SD card, but still the same error. Is there any code created by the file if it does not exist?
source share