ActivityCompat.requestPermissions(this, new String[]{READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE}, PackageManager.PERMISSION_GRANTED); //прописан в класссе
try { //так пробовал FileWriter writer = new FileWriter(getFilesDir() + "/my_file.txt"); writer.write("This is some text to save!"); writer.close();
//и так пробовал
FileOutputStream outputStream = openFileOutput("my_file.txt", Context.MODE_PRIVATE); outputStream.write("This is some text to save!".getBytes()); outputStream.close(); } catch(Throwable e) { e.printStackTrace(); resultView.append("Ошибка"); }
и так пробовал
FileOutputStream god=null;
try { god = openFileOutput("my_file.txt", Context.MODE_PRIVATE);
god .write("This is some text to save!".getBytes());
ошибка не вылезает и файла нет много чего перепробовал P.S версию sdk менять не могу т.к все летит к чертям P.S.S извиняюсь но вопрос решил удалить не могу увы
ActivityCompat.requestPermissions(this, new String[]{READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE}, PackageManager.PERMISSION_GRANTED); //прописан в класссе
try {
//так пробовал
FileWriter writer = new FileWriter(getFilesDir() + "/my_file.txt");
writer.write("This is some text to save!");
writer.close();
//и так пробовал
FileOutputStream outputStream = openFileOutput("my_file.txt", Context.MODE_PRIVATE);
outputStream.write("This is some text to save!".getBytes());
outputStream.close();
}
catch(Throwable e) {
e.printStackTrace();
resultView.append("Ошибка");
}
и так пробовал
FileOutputStream god=null;
try {
god = openFileOutput("my_file.txt", Context.MODE_PRIVATE);
god .write("This is some text to save!".getBytes());
god .close();
}
catch(Throwable e) {
e.printStackTrace();
resultView.append("Ошибка");
}
finally {
if (god != null) {
try {
god.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
AndroidManifest
<uses-permission android:name=" android.permission.READ _EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="32"
tools:ignore="ScopedStorage" />
ошибка не вылезает и файла нет много чего перепробовал
P.S версию sdk менять не могу т.к все летит к чертям
P.S.S извиняюсь но вопрос решил удалить не могу увы