是否有任何选项可以限制我们的 Android 应用程序缓存被清除?

Any option to restrict our Android application cache being cleared?

我们在android应用程序开发中是否有任何option/library来限制我们应用程序的缓存被清除?

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.

请帮助我进一步处理这个问题。 我们同时拥有混合 android 和原生 android 应用程序。

如果答案是否定的,如何restructure/avoid使用混合应用程序的缓存存储?

android:manageSpaceActivity=".ActivityOfMyChoice" 添加到您的清单的 application 标签中,例如:

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

然后 "Clear Data" 有一个按钮 "Manage Space" 启动 ActivityOfMyChoice 它适用于 UC 浏览器和海豚浏览器。

我对使用外部库限制 清除缓存 的 android 应用程序的研究是不可能的,除非从 android 更改我们应用程序的文件存储路径临时(缓存)文件夹到应用程序资产(根)文件夹。

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

这需要从提到的缓存存储路径更改为应用存储(即,将文件保存在资产文件夹中)

对于 CLEAR APP DATA 选项:

这可以通过将 android:manageSpaceActivity=".ActivityOfMyChoice" 添加到您的清单的应用程序标签来完成,例如:

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

完成后,应用会在应用存储选项中显示 "Manage Space" 按钮而不是 "Clear Data"。