I want to save file in Device internal storage Android/Ios
with path_provider. am saving file to storage with SharedPreferences if I am wring static path like /storage/emulated/0/Documents
this will work on some device but not work higher version. If the file is saved using path_provider
where to see this saved file?
Getting Path:
Future<String> get filePath async {
final directory = await getApplicationDocumentsDirectory();
return directory.path;
}
Save file to device storage:
final directory = await filePath;//directory path
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
sharedPreferences.setString(
'Key', DateTime.now().toIso8601String());
print('Save file to device storage');
File filePathName = File("$directory/api_json_file.txt");
print('Save Dir- $filePathName');
await filePathName.writeAsString(sharedPreferences.getString('Key').toString());