1
votes

Does we have any option/library in android app development to restrict our app's cache is being cleared?

We are facing a scenario based issue. Since, we are having offline app, which will be synced online whenever the user connected to network. In the meantime If the user runs some 'cleaning apps' erased all the offline data stored in our app.

Pl help me to proceed further this issue. We are holding both Hybrid android as well as Native android applications.

If the answer is NO, How to restructure/avoid using the cache storage of a HYBRID Applications?

2
I don't think so.rohitanand
The complete and entire point behind putting data in cache directories is to make it easy for the user to reclaim that space. If you do not want that behavior, do not put data in cache directories.CommonsWare
Any tips to avoid our app using the cache directories in a HYBRID android Applications?rajmathan

2 Answers

1
votes

My study on restricting Clear Cache of an android application using external library is not possible without changing file-storage path of our application from android temp(cache) folder to app asset(root) folder.

Default app cache storage path: internalStorage/Android/data/app_package_name/cache

This need to be changed from the mentioned cache storage path to app storage (ie, Keeping files in assets folder)

For CLEAR APP DATA option:

This can be done by adding android:manageSpaceActivity=".ActivityOfMyChoice" to the application tag of your Manifest like:

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

Once it done the app shows "Manage Space" button instead of "Clear Data" in app storage option.

0
votes

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 It's working for UC Browser and as well as dolphin browser.