3

The Instant Android documentation says that the following features are unsupported for instant apps:

  • Externally accessible content providers
  • Access to content providers from other applications

I am currently refactoring an Android app so that it supports instant apps. This app uses a content provider for storing data and is not externally accessible.

I wanna know if it is possible to use a content provider within an instant app which is only accessible inside that specific app. Currently it does instantiate the content provider but the content resolver returns null when trying to retrieve the provider. It does work with the installable app.

Prags
  • 2,457
  • 2
  • 21
  • 38
Richard
  • 31
  • 2
  • Maybe some info in this question provides some insights https://stackoverflow.com/questions/35510925/module-with-contentprovider – Entreco Feb 19 '18 at 13:45
  • "This app uses a content provider for storing data" -- why? – CommonsWare Feb 19 '18 at 13:57
  • @CommonsWare It implements the AbstractThreadedSyncAdapter, CursorAdapter and CursorLoader classes as stated in [this guide](https://developer.android.com/guide/topics/providers/content-provider-creating.html). – Richard Feb 19 '18 at 14:08
  • A `ContentProvider` is used to publish data to other apps. You do not need to use it internally. – CommonsWare Feb 19 '18 at 14:16
  • Regardless of wether ContentProvider should be used, the question still remains... Is it possible? If the existing app is already using it, it can be Troublesome to refactor – Entreco Feb 19 '18 at 23:30
  • @CommonsWare some apps use internal contentproviders for cursoradapters - it was a common way of doing things a few years ago – dazza5000 Feb 20 '18 at 04:01
  • How are you registering the content provider / are there different namespaces between the content provider and the instant app module? – dazza5000 Feb 20 '18 at 04:03
  • You can use the ContentProvider, but the SyncAdapter with its associated account will break at runtime since it's not accessible within an instant app. – Ben Weiss Feb 20 '18 at 21:38
  • @keyboardsurfer I figured that out as I have the ContentProvider working but the instant app crashes on the ContentResolver.requestSync method. The problem with my ContentProvider was a string resource in the AndroidManifest which did not get replaced somehow. Is there any way to work with the SyncAdapter or what is an alternative? – Richard Feb 21 '18 at 08:14
  • Can you file a bug to Google, then link to it back in here? It would be helpful for all, thanks! https://issuetracker.google.com/issues/new?component=316045&template=1018787 – Prags Feb 22 '18 at 05:46

0 Answers0