View user list
adb shell pm list users
Create new user
adb shell pm create-user [–profileOf USER_ID] [–managed] USER_NAME
adb shell pm create-user 10 godv
Start and switch users
adb shell am switch-user USER_ID
adb shell am start-user USER_ID
Install the application to a user
adb install –user USER_ID name.apk
delete users
adb shell pm remove-user USER_ID
For data security under multiple users, at the beginning of each new user creation, whether it is an external storage (External Storage) or an app data directory, Android has prepared an independent file storage for it
/storage/emulated/ has different user partitions
/storage/emulated/0
/storage/emulated/10
The code is viewed by different users taking the SDK as an example to obtain reflection
int uid = -1;
try {
Class clz = Class.forName("android.os.UserHandle");
Method m = clz.getDeclaredMethod("myUserId");
uid = (int) m.invoke(null);
} catch (Exception e) {
e.printStackTrace();
}
Uri under ContentResolver
content:// USER_ID @media/external/audio/media
To get different data under different users