My Android HTML application is losing values stored in localStorage when it shuts down. Anyone else see this issue?

后端 未结 5 1108
不知归路
不知归路 2020-12-24 08:01

I have a native Android 2.1 application that hosts a web view. I load up a site that contains javascript that uses the LocalStorage feature. When the application is runnin

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-24 08:21

    setDatabasePath() method was deprecated in API level 19. I advise you to use storage locale like this:

    webView.getSettings().setDomStorageEnabled(true);
    webView.getSettings().setDatabaseEnabled(true);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        webView.getSettings().setDatabasePath("/data/data/" + webView.getContext().getPackageName() + "/databases/");
    }
    

提交回复
热议问题