Skip to content Skip to sidebar Skip to footer

How To Store Data In Android Instant App And Restore It In Installed App

According to Google druging developing instant apps 'Best practices' is 'Keeping user state after app installation' https://developer.android.com/topic/instant-apps/ux-best-practic

Solution 1:

You can migrate data from InstantApp to installed app using StorageApi, example is here: google sample storage api. Just access InstantApps.getInstantAppsClient(this).instantAppData and you have it, addOnSuccessListener and here you go.

Solution 2:

Storage transfer from instant to installed app happens automatically on O+, but for platforms below O, you need to use this API. Please refer to Android Instant Apps FAQ: “How do I transfer data from an instant app to an installed app?”

https://developer.android.com/topic/instant-apps/faqs.html

For devices running Android 8.0 (API level 26) or higher, the instant app's data is transferred automatically when the APK installation begins. For devices running Android 7.1.1 (API level 25) or lower, call compatibility API in Google Play Services.

Solution 3:

The only option I can think of is saving that info on your server somehow and when the user installs the app recover it and continue where he left of. This is something that Google specified for apps with shopping carts (for example), where after the install the user will be able to continue shopping without losing any articles he may have chosen already. Also remember that through SmartLock you can save an account on the device and recover it later in the installed app. Hope this helps!

Solution 4:

I have been using couchbase lite to save my data on couchdb server then writing a filter then run pullReplication from the server using a sync gateway you can check out how it works here. Then in the android app i use the SharedPreferences to check if its the apps first run then run the sync

Post a Comment for "How To Store Data In Android Instant App And Restore It In Installed App"