1
  • 安卓10的话你AndroidManifest添加这个试试:
    android:requestLegacyExternalStorage="true"
    


    1250315081015627776  评论     打赏       开发小白
    • 不易  回复 @开发小白
      还是不行没有权限创建目录
      不易 2020-07-22 20:22   回复 1259774110133764096
  • 你把你的dir打出来看看吧,现在不用这种方式获取的,如果你的是新版本系统,已经不按这个规则来存放内容。

    1153952789488054272  评论     打赏       拉大锯
    • 不易  回复 @拉大锯
      D/MainActivity: dir is: /storage/emulated/0/hetan/ D/MainActivity: path is: /storage/emulated/0/hetan/summer.jpg W/System.err: java.io.IOException: No such file or directory at java.io.UnixFil
      不易 2020-07-22 20:20   回复 1259774110133764096
    • 不易  回复 @拉大锯
      dir 的路径是这个 /storage/emulated/0/hetan/
      不易 2020-07-22 20:21   回复 1259774110133764096
    • 不易  回复 @拉大锯
      创建目录失败
      不易 2020-07-22 20:21   回复 1259774110133764096
    • 不易  回复 @拉大锯
      请问新版本的是用什么存放内容的百度半天都没有找到 谢谢
      不易 2020-07-22 20:27   回复 1259774110133764096
    • 拉大锯  回复 @不易
      当你找到一个过时的API,可以去看这个过时的API上面有什么说明呀,上面会告诉你用什么API的。
      拉大锯 2020-07-22 20:28   回复 1153952789488054272
    • 不易  回复 @拉大锯
      大佬你是说我的刷新媒体那个过时了嘛
      不易 2020-07-22 20:42   回复 1259774110133764096
    • 拉大锯  回复 @不易
      Environment.getExternalStorageDirectory(),这个API过时了,你可以点进去看看,顶部有说明告诉你适用什么去获取路径的。
      拉大锯 2020-07-22 20:44   回复 1153952789488054272
    • 不易  回复 @拉大锯
      好的我去看看
      不易 2020-07-22 20:49   回复 1259774110133764096
    • 不易  回复 @拉大锯
      感谢哦
      不易 2020-07-22 20:52   回复 1259774110133764096
    • 不易  回复 @拉大锯
      获取的是外部路径但是系统相册检测不到照片是什么原因呢 /storage/emulated/0/Android/data/com.example.customdome/files/Pictures/202007222759.jpg存储的路径是这个
      不易 2020-07-22 21:31   回复 1259774110133764096
    • 不易  回复 @拉大锯
      照片也是创建成功了的
      不易 2020-07-22 21:31   回复 1259774110133764096
    • 不易  回复 @拉大锯
      手机文件管理器里面没有这个目录
      不易 2020-07-22 21:33   回复 1259774110133764096
    • 拉大锯  回复 @不易
      你添加图片以后,你需要发个广播通知媒体系统去更新呀。要不你从内容提供者里拿的数据没有新的图片呀。
      拉大锯 2020-07-22 21:49   回复 1153952789488054272
    • 不易  回复 @拉大锯
      Intent scanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); scanIntent.setData(Uri.fromFile(externalFilesDir)); sendBroadcast(scanIntent); 这样对嘛 我用没有效果
      不易 2020-07-22 22:34   回复 1259774110133764096
    • 不易  回复 @拉大锯
      说过时但是API里面没有替代的
      不易 2020-07-22 22:35   回复 1259774110133764096
    • 拉大锯  回复 @不易
      看官方文档嘛,官方文档里肯定有说明。
      拉大锯 2020-07-22 23:13   回复 1153952789488054272
    • 不易  回复 @拉大锯
      看到脑壳大😂
      不易 2020-07-22 23:42   回复 1259774110133764096
    • 不易  回复 @拉大锯
      感谢大佬哦辛苦您了
      不易 2020-07-23 00:06   回复 1259774110133764096
相关问题
拉大锯迷人弟 · 文件存储 / 本地存储
2020-08-08 05:27 720 5
2023-11-21 15:11 13 2
陈钱罐16 · 领券联盟
2023-11-11 18:09 23 8
哈哈android · AOSP
2023-11-10 15:52 13 12
2023-11-10 00:26 22 10
zhanghengze · Android
2023-10-26 21:52 22 8