Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download content when app is updated via google play?

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].

like image 606
Prateek Avatar asked Nov 15 '13 06:11

Prateek


People also ask

How long does Google take to update app?

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.

Does Google Play automatically update apps?

When updates are available, the app updates automatically. To turn off automatic updates, turn off Enable auto update.


2 Answers

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.

like image 69
Thommy Avatar answered Sep 27 '22 19:09

Thommy


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.

like image 24
Szymon Avatar answered Sep 27 '22 17:09

Szymon