Share file between activites
1. Set this same shared user id in manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.a"
android:versionCode="1"
android:versionName="1.0"
android:sharedUserId="com.example.id">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.b"
android:versionCode="1"
android:versionName="1.0"
android:sharedUserId="com. example.id">
2. Get another app’s context with createPackageContext()
Context otherContext = context.createPackageContext("com.example.a", 0);
AssetManager am = otherContext.getAssets();
Comments
Post a Comment