我有一个应用程序,允许用户在线玩游戏或将游戏缓存到本地。当他们将游戏转换为缓存模式时,我不希望他们失去进度。
在KitKat之前,您可以设置localstorage目录,但我需要新的手机支持此功能。
在KitKat之前,您可以设置localstorage目录,但我需要新的手机支持此功能。
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
playingField.getSettings().setDatabasePath("/data/data/" + playingField.getContext().getPackageName() + "/databases/");
}
我找不到替代的方法。因此,这里有两个目录:
root@ghost:/data/data/com.myapp.android/app_webview/Local Storage #
ls -la
total 80
drwx------ 2 u0_a165 u0_a165 4096 2017-01-06 11:51 .
drwxrwx--x 4 u0_a165 u0_a165 4096 2017-01-06 11:41 ..
-rw------- 1 u0_a165 u0_a165 4096 2017-01-06 11:51 file__0.localstorage
-rw------- 1 u0_a165 u0_a165 0 2017-01-06 11:51 file__0.localstorage-journal
-rw------- 1 u0_a165 u0_a165 4096 2017-01-06 12:02 http_cdn.myapp.com_0.localstorage
-rw------- 1 u0_a165 u0_a165 0 2017-01-06 12:02 http_cdn.myapp.com_0.localstorage-journal
有人解决了这个问题吗?
我可能会在活动的onPause()
期间尝试同步文件,但我想知道是否有更优雅的解决方案 - 比如集中存储。