我对android多用户分离外部存储有一些疑问
假设所有者安装com.example.test包,其中包含以下代码
File[] path = getExternalFilesDirs(null);
Log.d("getExternalFilesDirs",path.toString());
所有者的日志是
/storage/sdcard/Android/data/com.example.test/files
既然已经安装了相同的应用程序,我会在不同的应用程序上运行相同的应用程序 用户。
不同用户的上述代码的日志是
/storage/sdcard/Android/data/com.example.test/files
我的困惑是所有者和其他用户共享的相同位置,我期待的 位置是对用户私密的。
对于多个用户的外部存储,我期待这样的事情
/storage/sdcard/Android/data/user/0/com.example.test/files /storage/sdcard/Android/data/user/13/com.example.test/files
如何为外部存储完成多用户分离? 而在不同用户下运行时,以下内部存储代码显示
path=getFilesDir();
Log.d("getFilesDir",path.toString());
/data/user/10/com.example.test/files --> for user1
/data/user/11/com.example.test/files --> for user2
/data/user/13/com.example.test/files --> for user3
在这里,我可以看到内部存储中的多用户分离。 所有实验均在Google的AVD for Nexus 4,Target Name Android 5.0,API Level 21上完成。
感谢您的帮助。
- Batsayan