首页 > 解决方案 > 应用程序特定目录未在 android 的外部存储目录中创建

问题描述

我的应用程序名称是“com.example.storagecheckapp”

1)我已经使用命令“adb install storagecheckapp.apk”安装了应用程序

  1. 检查是否在存储目录中创建了应用程序特定目录。但默认情况下不创建该目录

adb shell ls -la /storage/emulated/0/Android/data/com.example.storagecheckapp /storage/emulated/0/Android/data/com.example.storagecheckapp :没有这样的文件或目录

  1. 然后,我调用了 api“File(getExternalFilesDir(null);”这有助于在外部存储目录中创建“com.example.storagecheckapp”。

adb shell ls -la /storage/emulated/0/Android/data/com.example.storagecheckapp/

共 9 个

drwxrwx--x 3 u0_a146 sdcard_rw 3488 2021-02-06 14:45。

drwxrwx--x 30 根 sdcard_rw 3488 2021-02-06 15:39 ..

drwxrwx--x 2 u0_a146 sdcard_rw 3488 2021-02-06 14:45 文件

问题是:为什么没有在外部存储中创建应用程序特定目录(安装 thapp 后自动创建)?

我已经检查了 sdk 29 和 30,同样的问题仍然存在吗?请建议..

标签: androidandroid-studioandroid-external-storageandroid-11

解决方案


为什么没有在外部存储中创建应用程序特定目录(安装 thapp 后自动创建)?

这不是 Android 的工作方式。Android 会根据需要延迟创建目录。毕竟,并不是每个 Android 应用程序都需要该目录。


推荐阅读