赞
踩
- 1、申请读写权限(先在config.json中申请,再使用JAVA代码动态申请)ohos.permission.READ_USER_STORAGE和ohos.permission.WRITE_USER_STORAGE。
-
- 2、获取File对象:
-
- File file = new File(xxx);
-
- 关于路径有如下参考:
-
- context.getCacheDir().getPath() //缓存路径
-
- context.getExternalCacheDir().getPath(); //自身应用缓存
-
- context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS).getPath();
-
- context.getCodeCacheDir().getPath();
-
- getDistributedDir().getPath();
-
- getFilesDir().getPath();
-
- getNoBackupFilesDir().getPath();
-
- getPreferencesDir().getPath();
-
- context.getDatabaseDir().getPath();
-
- context.getDataDir().getPath();
-
- context.getDir().getPath();

注意:目前仅支持访问自己应用目录下的文件,估计要和苹果对标,对用户来说很好,对开发者可谓难受至极!!!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。