Reputation: 5872
From the documentation:
The name of a Linux user ID that will be shared with other applications. By default, Android assigns each application its own unique user ID.
Say I have an app that does not specify android:sharedUserId in the AndroidManifest.xml file.
Is the default sharedUserId Android generates (see above documentation) set in the build (same for this app on all devices) or is a different sharedUserId being generated on each device the app is installed?
Upvotes: 5
Views: 1567
Reputation: 3148
Android generate random unique ID for each application you installed on your device.
You can get this value by:
adb shell dumpsys package com.example.myapp | grep userId=
or in code with :
int uId = getPackageManager().getApplicationInfo("com.example.myapp",PackageManager.GET_META_DATA).uid;
But if you set android:sharedUserId
with the same value for two or more apps, they will all share the same ID — provided that their certificate sets are identical.
Apps with the same user ID can access each other's data and, if desired, run in the same process.
Upvotes: 2