title: android:sharedUserId="android.uid.system" Obtaining Files from SDCard
body: <p>I have a scenario in Android (SDK 19/KitKat 4.4.2)  where my application is to be signed as a system level application (<strong>App 1</strong>) using android:sharedUserId="android.uid.system" in the Manifest.xml. This means that this application is unable to write or read from SD cards, be they external or built into the device.</p>
  
  <p>If I needed to obtain a large file from the SDCard and read it into my application, what is the best approach to do this?</p>
  
  <p>My goal is simply to obtain image files from the SDCard. However, even images can be relatively big if they're uncompressed bitmaps.</p>
  
  <p>I've tried the following approaches:</p>
  
  <ol>
  <li><p>Creating a new application that is not signed as the system user (<strong>App2</strong>). Starting a service that exists in this <strong>App2</strong> from <strong>App1</strong>, then reading in the file from the SD card from here, then obtaining the byte[] of the file, and sending it over via AIDL to <strong>App1</strong> in chunks. This works in terms of reading the file from the SDCard and sending it over, however AIDL has a cap of 1mb for each transaction and is also very slow to a point where I should probably limit the size of images allowed to be given to the application to make this feature usable. Not the most ideal in my opinion.</p></li>
  <li><p>I've tried using FileProvider in <strong>App 2 (UID: 10007)</strong>, however in this scenario I need to not open any graphical interface to select the file I want and a target application. I need to just send it over immediately to <strong>App 1  (UID: 10047)</strong> or obtain it immediately from <strong>App1</strong>. I'm not sure if it's possible to use FileProvider without those gui steps. I tried just creating the Uri from <strong>App2</strong> then sending the Uri to <strong>App1</strong> over AIDL, then giving permissions via context.grantUriPermissions(packageName,uri,READ/WRITE), but always end up with a security error where <strong>App1</strong> does not have permission to read the uri <strong>App2</strong> is providing.</p></li>
  </ol>
  
  <p>java.lang.SecurityException: No permission grant found for UID 10047 and Uri content://com.test.sdcard/folder/img.png</p>
  
  <p>Where UID 10047 is <strong>App 1</strong> and UID 10007 is <strong>App 2</strong>. </p>
  
  <p>Any alternative solutions to this problem?</p>