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

后端 未结 5 1114
不知归路
不知归路 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:19

    only need these two lines:

    this.getSettings().setDomStorageEnabled(true); //enable to use "window.localStorage['my']='hello1'", in webview js on >= android 2.0
    this.getSettings().setDatabasePath("/data/data/"+this.context.getPackageName()+"/databases/"); //if no set or wrong path, variables disappear on killed
    

提交回复
热议问题