I'm trying to write data into a text file on the sd-card. However, the result is, that the file is written in the internal storage (internal storage/myNewFolder). Where is my mistake in the code part? Here's the interesting part with the paths:
String state;
state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state))
{
File Root = Environment.getExternalStorageDirectory();
File Dir = new File(Root.getAbsolutePath()+"/myNewFolder");
if (!Dir.exists()) {
Dir.mkdir();
}
File file = new File(Dir,"TrackLog.txt");
..........code skipped ........
else
{
Toast.makeText(getApplicationContext(),"SD not found",Toast.LENGTH_LONG).show();
}
I skipped the rest of the code as it shouldn't be of interest for this problem.
edit: now changed to
File Root = Environment.getExternalStorageDirectory();
File Dir = new File(Root.getAbsolutePath()+"/myNewFolder");
if (!Dir.exists()) {
Dir.mkdir();
}
File file = new File(Dir,"TrackLog.txt");
So the file is simply written into myNewFolder in the internal storage - which is also fine with me.