2

Our android app stores user data on a server. That is fine as long as the user does not uninstall the app. Once he does that, we need to delete any user data from the server. Problem is, that we do not know when the user uninstalls the app.

Can anyone please help me with this?

Tim
  • 41,901
  • 18
  • 127
  • 145
  • I think you can't do that. You can check when the user have last accessed/changed their data and, depending on this value, delete old records. But you have no guarantee that they actually deleted your app. – Peanut Apr 28 '15 at 09:52
  • But that would mean, you have keep user data longer than the user usually would accepted this. I guess the expectation is that all data is gone when I delete an app. Wonder how this tallys with EU privacy laws. – Thomas Wrobel Apr 29 '15 at 10:59
  • What if an app is never uninstalled? e.g. if a mobile phone is lost or does not work anymore. Do you want to keep this data until eternity? – Peanut Apr 29 '15 at 11:04
  • That is a good point. – Thomas Wrobel Apr 30 '15 at 09:39

2 Answers2

1

Although it is possible to listen for uninstall, you shouldn't be able to make network calls to tell your server to delete files. Instead you can either:

  1. Clear data the next time the user installs the app (registers a new device).

  2. Have the app ping your server every n days. Every n+1 days you run a server script to clear out data for users that haven't pinged in n days. Tim Castelijns correctly points out that this will cause data erasure if the user is offline for n days. So this option depends on what data you are keeping, and how long the user can expect it to stay on the server.

  3. If you really need to do something before uninstall, you can try this solution: How can an app detect that it's going to be uninstalled?

Community
  • 1
  • 1
A J
  • 1,080
  • 7
  • 11
  • What if the user has his phone off for n+1 days? Or simply no internet connection. It would not really be cool to see all your data deleted for that reason – Tim Apr 28 '15 at 13:41
  • @TimCastelijns You are correct, #2 would lead to miserable UX (which is bad) if n is short enough. But depending on n (365, for example), it could be reasonable to say that if a device has not checked in for over n days, it is no longer being used. – A J Apr 28 '15 at 13:56
  • That's true. 365 seems long however. Something like a month should be sufficient then – Tim Apr 28 '15 at 13:59
  • Can you please point me to some code which allows an app to listen for its own uninstall? – Eugen Pechanec Apr 28 '15 at 14:04
  • This one is the most interesting: http://stackoverflow.com/questions/19475765/androidlisten-to-own-application-uninstall-event Dolphin browser is magically able to do what OP wants, but it seems they are exploiting some security hole that is not publicized. That said, you can always listen for ACTION_PACKAGE_REMOVED, though you won't be able to do anything when your own uninstall happens. – A J Apr 28 '15 at 15:05
0

Partly you can do that.

By putting following intent-filter in Manifest.xml you can show user activity which uninstalls app (this can be your app too).

<intent-filter>
       <action android:name="android.intent.action.VIEW" />
       <action android:name="android.intent.action.DELETE" />
       <category android:name="android.intent.category.DEFAULT" />
       <data android:scheme="package"  />
</intent-filter>

You can even filter package name, which means when your app is uninstalling it prompt you.

Murtaza Khursheed Hussain
  • 15,176
  • 7
  • 58
  • 83