I have this bit of code that exports a list into a csv file. It saves it on the device, but I don't know how to actually access the file itself, here is the code:
getCsv(List<Email> mailList) async {
List<List<dynamic>> rows = List<List<dynamic>>();
for (int i = 0; i < mailList.length; i++) {
List<dynamic> row = List();
row.add(mailList[i].id);
row.add(mailList[i].email);
rows.add(row);
setState(() {
mailList = finalExport;
});
}
await SimplePermissions.requestPermission(Permission.WriteExternalStorage);
bool checkPermission = await SimplePermissions.checkPermission(
Permission.WriteExternalStorage);
if (checkPermission) {
String dir =
(await getExternalStorageDirectory()).absolute.path + "/user";
String file = "$dir";
File f = new File(file + "_maillist.csv");
String csv = const ListToCsvConverter().convert(rows);
f.writeAsString(csv);
}
}
And firing that function, it saves it here on the emulator:
'/storage/emulated/0/Android/data/com.example.myapp/files/user_maillist.csv'
How would I actually be able to access that file on my device, maybe copy it to somewhere where I can open it or even maybe send that file through mail, just so I can actually open it. Thank you!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…