0

I have an application that saves some data in Shared Preferences and in a SQLite.

I need to know if the user goes to Settings->Application Manager->Myapp and clears data. In this case I need to send a broadcast to inform some 'satellite' applications that get data from my app so they stop their services.

Is there a Listener for this or a workawroung for this?

Thank you!

geoak
  • 442
  • 7
  • 18

1 Answers1

2

You can manage this by adding this line android:manageSpaceActivity=".path.to.MyActivity" to the <application> tag in the Android Manifest. The user won't be able to clear data but will be brought to the Activity. There you can manually let the user clear data, or do whatever you like.

From the docs:

android:manageSpaceActivity
The fully qualified name of an Activity subclass that the system can launch to let users
manage the memory occupied by the application on the device. The activity should also be
declared with an <activity> element.

The button in the Apps section of Settings won't say 'Clear Data' but will say 'Manage Space'enter image description here

Don't forget to add the activity under an <activity> tag in the manifest as well

Good luck!

dumazy
  • 13,857
  • 12
  • 66
  • 113