How to disable the Clear Data button in Application info of Manage application
Add android:manageSpaceActivity=".ActivityOfMyChoice"
to the application
tag of your Manifest like:
<application android:label="MyApp" android:icon="@drawable/icon"
android:manageSpaceActivity=".ActivityOfMyChoice">
Then instead of "Clear Data"
, there is a button for "Manage Space"
which launches ActivityOfMyChoice
As far as I have been able to tell, this works 100% of the time.
AndroidManifest.xml
<application
android:manageSpaceActivity="[packageName].ManageSpaceActivity"
...
...
>
<activity
android:name="[packageName].ManageSpaceActivity"
android:screenOrientation="portrait" />
it will call my activity, but:
public class ManageSpaceActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
finish();
}// onCreate
}
and the Activity is dead at creation, I love tricks :)
Now you can press the "Manage space" as much as you want! :))
- if you need you can do custom data / cache delete at ManageSpaceActivity
, but you can keep your data, which do you want.
Up votes on Jakar answer too pls!
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)