So this is the first time I am going to send an update for my app and I don't know about what actully happens when an app is updated via google-play,
Here are some questions those I couldn't get answer of :
What is actually updated and how this process works i.e. methods or callbacks when update is done ?
What happens to the shared-preferences file, the name values pairs change/reset ?
Let's say I want to download some file from a server , when the app is updated via google play and do some db operations with that file in the background. How can I approach this in the right way.
--Edit--
To make it more clear I want to automatically do some processing when the app is updated by user and he doesn't bother to open the app and to achieve this I am looking for a trigger that is provided by google play to my app by any intent [implicit or explicit].
Google Play typically checks for app updates once a day, so it can take up to 24 hours before an app update is added to the update queue.
When updates are available, the app updates automatically. To turn off automatic updates, turn off Enable auto update.
You need to implement a Broadcast Receiver that gets notified when the Paackage is beeing replaced:
In your Manifest include:
<receiver android:name="my.package.MyReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REPLACED"/>
<data android:scheme="package" />
</intent-filter>
</receiver>
The class MyReceiver
needs to extend android.content.BroadcastReceiver
To Answer your second question: The SharedPreferences aren't affected by an update through Google Play, as aren't the files in your App's data-Folder.
One way of checking if a new version has been installed is to use shared preferences. When the app is opened, you can check if an entry for that version is present. If it's not, a new version has been installed. After your processing is done, you can save the current version number in shared preferences.
As for your second question, shared preferences are not lost or reset by the update process. They stay as they were.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With