android multi user separation for external storage

2.1k Views Asked by At

I have some doubt on android multi user separation of external storage

Say the owner installs com.example.test package, which has the following code

File[] path = getExternalFilesDirs(null);
Log.d("getExternalFilesDirs",path.toString());

The log for owner is

/storage/sdcard/Android/data/com.example.test/files

Now since the same app is already installed, I run the same app on different user.

The log for the above code for different user is

/storage/sdcard/Android/data/com.example.test/files

My confusion is same location shared by owner and other users, I expected the location to be private to users.

I expected somthing like this for external storage for multiple users

/storage/sdcard/Android/data/user/0/com.example.test/files /storage/sdcard/Android/data/user/13/com.example.test/files

How Multi-user separation is done for external storage? Whereas the following code for internal storage when run under different users shows

            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

Here I can see the multi user separation in internal storage. All the experiments were done on AVD for Nexus 4 by Google , Target Name Android 5.0 , API Level 21.

0

There are 0 best solutions below