Can't write my string to file on external storage. I have write and read external storage permissions in Manifest. Also added this one
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
from previous similar questions. But nothing seems to work. Thanks in advance
if (isSDCARDAvailable()) {
writeToFile(resultJson.toString());
}else {
Log.d(TAG, "false");
}
private void writeToFile(String string){
String filename = "routes.txt";
File sdcard = Environment.getExternalStorageDirectory();
File file = new File(sdcard.getPath(), filename);
try {
FileWriter writer = new FileWriter(file);
writer.write(string);
writer.flush();
writer.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public static boolean isSDCARDAvailable(){
return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
}