getLocalDocumentDir method
获取应用程序的目录,用于存储只有它可以访问的文件。只有当应用程序被删除时,系统才会清除目录。
在iOS上,它使用“NSDocumentDirectory”API。如果数据不是用户生成的,请考虑使用GetApplicationSupportDirectory
。
在Android上,这在上下文中使用了“getDataDirectory”API。如果数据对用户可见,请考虑改用getExternalStorageDirectory。
文档目录: /data/user/0/com.xx.xxx/xxx
Implementation
Future<String?> getLocalDocumentDir() async {
try {
final appDocDir = await getApplicationDocumentsDirectory();
return appDocDir.path;
} catch (e) {
logger.e(tag: TAG, e);
return null;
}
}