title: Two Application's using sharedUserID - createPackageContext issue
body: <p>I have two separate applications. I would like appB to have access to the database within appA's code. I do not want to use a content provider in this instance.</p>
  
  <p>I have read the post on SO regarding this and followed the instructions 
  (<a href="https://stackoverflow.com/questions/7053809/share-sqlite-database-between-2-android-apps">Share SQLite database between 2 android apps?</a>).</p>
  
  <p>What I have done:</p>
  
  <p>The Android Manifest of the AppA:</p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.micode.primaryapplication"&gt;
  
      &lt;application
          android:sharedUserId="com.micode.sharedid"
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:screenOrientation="portrait"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity android:name=".MainActivity"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>The Android Manifest of AppB:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.micode.secondaryapplication"&gt;
  
      &lt;application
          android:sharedUserId="com.micode.sharedid"
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:screenOrientation="portrait"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity android:name=".MainActivity"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>AppA creates a database, AppB needs to access the database.</p>
  
  <p>The following code is used in AppB:</p>
  
  <pre><code>package com.micode.secondaryapplication;
  
  import android.content.Context;
  import android.database.Cursor;
  import android.database.sqlite.SQLiteDatabase;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.TextView;
  
  public class MainActivity extends AppCompatActivity {
  
      Button btnExit;
      TextView txtViewDisplay;
      Context sharedContext;
  
      SQLiteDatabase db = null;
      private static String DBNAME = "Contacts.db";
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          setupContext();
      }
  
      private void setupContext()
      {
          try {
              sharedContext = this.createPackageContext("com.micode.primaryapplication", Context.CONTEXT_INCLUDE_CODE);
              if (sharedContext == null) {
                  return;
              }
          } catch (Exception e) {
              String error = e.getMessage();
              System.out.println(error);
              return;
          }
      }
  </code></pre>
  
  <p>I have tried building both applications with the exact same signing key, i.e. Build/Generate Signed APK and uninstalled any previous instances prior to installation.</p>
  
  <p>I am also trying to run this in debug mode, i.e. install AppA in debug mode, then install AppB in debug mode.</p>
  
  <p>In the latter case I see the following error:</p>
  
  <p><strong><em>Requesting code from com.micode.primaryapplication (with uid 10226) to be run in process com.micode.secondaryapplication (with uid 10227)</em></strong></p>
  
  <p>This error is hit when the following line is executed. </p>
  
  <pre><code>this.createPackageContext("com.micode.primaryapplication", Context.CONTEXT_INCLUDE_CODE);
  </code></pre>
  
  <p>It leads me to believe that the problem is with the installation, i.e. it seems to me that the shareduserid has been ignored and thus the two applications are not sharing the same UID, instead having unique UIDs.</p>
  
  <p>To be clear, I only have two applications that are using these shared user ids.</p>
  
  <p>Any help is greatly appreciated...</p>