如何以编程方式将文件从根目录复制到非根目录 android phone 中的另一个目录?
How can i copy a file from a rooted directory to another directory in a non rooted android phone prorammatically?
我可以将文件从 data/data/something/ 这样的根目录复制到非根目录 android phone 中的另一个目录吗?
如果是那么怎么办?
如果不是,那么 whatsapp 如何将其密钥文件存储在所有 phone 目录 data/data/com.whatsapp.com 中(非根 phones 也)
简答:是
长答案:
是的,但仅限于应用程序的目录。该应用程序可以访问自己的数据目录(例如 /data/data/app.package.name/),但无法访问 /data 分区中的其他目录。您可以在没有额外权限或工具的情况下将文件存储在自己的目录中,但您不能在没有 root
的情况下使用其他数据目录
您可以使用 context.getDataDir()
获取该目录的路径,但它在 api lower 24 上不可用。您应该使用 context.getFilesDir()
、context.getCacheDir()
或 context.getDir(String, int)
而不是
我可以将文件从 data/data/something/ 这样的根目录复制到非根目录 android phone 中的另一个目录吗? 如果是那么怎么办? 如果不是,那么 whatsapp 如何将其密钥文件存储在所有 phone 目录 data/data/com.whatsapp.com 中(非根 phones 也)
简答:是
长答案: 是的,但仅限于应用程序的目录。该应用程序可以访问自己的数据目录(例如 /data/data/app.package.name/),但无法访问 /data 分区中的其他目录。您可以在没有额外权限或工具的情况下将文件存储在自己的目录中,但您不能在没有 root
的情况下使用其他数据目录您可以使用 context.getDataDir()
获取该目录的路径,但它在 api lower 24 上不可用。您应该使用 context.getFilesDir()
、context.getCacheDir()
或 context.getDir(String, int)
而不是