Last time i was able to save it on my file manager and last week when i try to save it again. I have an error this is my android manifest
android manifest.xml:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE">
My Activty codes:
FileWriter fileWriter = null;
String address = "/sdcard/GPSTracker.txt";
try {
fileWriter = new FileWriter(address, true);
} catch (IOException e) {
e.printStackTrace();
}
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
String str1 = textLatLong.getText().toString().trim();
String use1 = username.getText().toString();
//Add new line for existing textfile
try {
// First, read the lines
List<object> lines = Files.lines(Paths.get(address)).collect(Collectors.toList());
long count = lines.size();
bufferedWriter.write(count + "," + serialNumber + "," + use1 + "," + str1 + "," + filename1);
bufferedWriter.newLine();
} catch (IOException e) {
e.printStackTrace();
}
try {
bufferedWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
Toast.makeText(MainActivity.this, "Sucessfully Saved", Toast.LENGTH_SHORT).show();
What I have tried:
I tried any method as far as i could but this is always an error.
W/System.err: java.io.FileNotFoundException: /sdcard/GPSTracker.txt (Permission denied)
at java.io.FileOutputStream.open0(Native Method)