How to Disable the Clear Data Button in Application Info of Manage Application

How to disable the Clear Data button in Application info of Manage application

There is no way to prevent the user from clearing your app data. The manifest option you mention is intended for system apps only and you, as a developer, have no way to install system apps.

Please see this discussion for details - particularly this response from Diane Hackborn (Android framework engineer)

How to disable Clear data button in android mobile

You Cant do that

But ,instead of the clear data , Manage Space will visible in the Settings Screen To do this,add this to your application tag in the manifest file..

android:manageSpaceActivity="com.packagename.appname.activities.ManageSpaceActivity"

When you invoke that button your appr ManageSpaceActivity will be launched

Check this , this for more info..

Avoid deleting the data from database on clicking 'clear data' button in the app settings on android device

Finally I found some solution, If you make application system administrator then its not possible to clear data and uninstall app

Setting manageSpaceActivity makes Clear Data button disabled on API 28 (Pie)

Try to add an absolute path to your class, instead:

<application android:label="MyApp" android:icon="@drawable/icon" 
android:manageSpaceActivity=".ActivityOfMyChoice">

use:

<application android:label="MyApp" android:icon="@drawable/icon" 
android:manageSpaceActivity="com.example.ActivityOfMyChoice">

Android prevent deleting application offline data or database on Clear data event


How I can prevent my offline data from deleting?

You can't. It's the user's device, not yours, and so it is not your data — it is the user's data. The user can do what the user wants.

Is there any way to save offline data at secure place and access it only through application?

Internal storage prevents direct access to your files by the user or by other apps. It does not prevent the user from getting rid of those files, either through "clear data" or by uninstalling your app.

Can we disable, Clear Data event for my application?

Not really. On some versions of Android, you can get control when the user clicks that button. However:

  • Do not assume that all devices will support this
  • Device manufacturers might provide other means for the user to clear the data
  • The user can still uninstall and reinstall the app, which will clear the data

Does “Clear Data” also kill the app?

Clear Data does kill the app, and always has.

"Force Stop" has gone through various iterations of meanings. It used to mean to just kill all processes and services, and clearing data would also do the same as a force stop. There were also older iterations of the platform that were not as good as figuring out when to disable the button, which is probably why you are seeing it remain enabled in 2.2.

However in 3.2 I believe the meaning of "Force Stop" change to put the application in a state where it would not be able to run until the user had done something to explicitly start it (such as launching it from launcher, selecting it as an input method, etc). When that change was made, "Clear Data" continued to just kill the processes and stop its services, so the app was not in the full stopped state so the button remains enabled.



Related Topics



Leave a reply



Submit