I want to create a textfile on my sdcard. I found lots of codesamples and tried them. None of them responded any Exception so i expected them to work, but when I was exploring my sdcard, I could not find a textfile. Here is the attempt I am trying:
try {
File sdcard = Environment.getExternalStorageDirectory();
File myFile = new File(sdcard,"text.txt");
myFile.createNewFile();
FileOutputStream fOut = new FileOutputStream(myFile);
OutputStreamWriter myOutWriter =
new OutputStreamWriter(fOut);
myOutWriter.append(encodedString); // this is a long string
myOutWriter.close();
fOut.close();
Toast.makeText(getBaseContext(),
"written to: "+myFile.getAbsolutePath(),
Toast.LENGTH_SHORT).show();
Here is what the Toast is telling me: What I expect: "written to: /sdcard/text.txt" What I get: "written to: /storage/emulated/0/text.txt"
Why is the app not saving the textfile as intended onto the sdcard and what do I have to change in order to make it do it?