Reputation: 3270
I have two applications. If one application is already installed on Android. The second application should use the credentials of the first application. How can I achieve sharing app credentials in Android?
Thanks,
Upvotes: 4
Views: 2358
Reputation: 15137
First of all, update the manifest of both of your apps to look like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yourpackage.firstapp" android:versionCode="1"
android:versionName="1.0.0"
android:sharedUserId="com.your.userId">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yourpackage.secondapp" android:versionCode="1"
android:versionName="1.0.0"
android:sharedUserId="com.your.userId">
Now let's say in your first app, you save the username/password as SharedPrefs or some xml file. When second app launches, it can now have access to the private directory of the first app, by looking for the sharedprefs file at /data/data/com.yourpackage.firstapp/shared_prefs/
If the first app's shared_prefs path exists, then you can open it and read the user/pass credentials.
Upvotes: 1