I have a requirement to save a file in Android external SD card. I have tried using this source code but it saves file in internal memory of phone.
Here is my code.
try {
File newFolder = new File(Environment.getExternalStorageDirectory(), "TestFolder");
if (!newFolder.exists()) {
newFolder.mkdir();
}
File file = new File(newFolder, "MyTest" + ".txt");
if (!file.exists()) {
file.createNewFile();
}
Toast.makeText(MainActivity.this, "Created Successfully!", Toast.LENGTH_SHORT).show();
} catch (Exception e) {
e.printStackTrace();
}