我写了一个插件来通过Dart访问
Android上的ExternalStorageDirectory.
这个插件的android特定代码:
@Override
public void onMethodCall(MethodCall call, Result result) {
if (call.method.equals("getUserDataDirectory")) {
String path = Environment.getExternalStorageDirectory().getAbsolutePath();
result.success(path);
} else {
result.notImplemented();
}
}
返回的路径是正确的存储/模拟/ 0.但现在如果我尝试迭代抛出目录我得到一个权限被拒绝.
error.log中
[ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter ( 3381): FileSystemException: Directory listing failed, path = '/storage/emulated/0/' (OS Error: Permission denied, errno = 13)
E/flutter ( 3381): #0 _Directory._fillWithDirectoryListing (dart:io-patch/directory_patch.dart:32)
E/flutter ( 3381): #1 _Directory.listSync (directory_impl.dart