是否可以列出另一个应用程序的缓存目录中的文件?

时间:2016-04-04 13:44:31

标签: android file

documentation中所述,内部存储文件是应用程序专用的。

但是,有没有办法只访问ex的列表。缓存另一个应用程序的目录文件?

Context context = createPackageContext(packageNameOfAnotherApp, 0);
File directory = context.getCacheDir();
directory.listFiles(); // this will return null, as do list()

2 个答案:

答案 0 :(得分:0)

不,显然出于安全原因。 您只能访问已将其编写的其他应用程序的数据写入可公开阅读的目录,或使用ContentProvider

答案 1 :(得分:0)

除非设备已植根且您的应用程序具有提升的权限,否则您无法直接访问其他应用程序的私有数据。