Is there a system setting table or API I can check to see if the "Multiple users" setting is turned on in Settings -> System -> Advanced -> Multiple users?
Thanks!
Is there a system setting table or API I can check to see if the "Multiple users" setting is turned on in Settings -> System -> Advanced -> Multiple users?
Thanks!
For API level 24 and above, you can use the method UserManager.supportsMultipleUsers(), which returns whether the device supports multiple users in boolean
.
Before API level 24, there are no methods to check this without system permissions. There can be a workaround, like getting the count of users using the method getUserCount(). Again this also needs android.permission.MANAGE_USERS
permission.
After a few hours of searching, I found the answer by browsing /data/system/users/0 and looking through settings_system.xml, settings_secure.xml, and settings_global.xml. It turns out what I'm looking for is "user_switcher_enabled" in settings_global.xml.
Here's my code:
The check for UserManager.supportsMultipleUsers() is probably not needed, but just in case the preference is somehow bogus on devices that don't actually support multiple users.
If there's anything you want to add to this answer, please comment below.