2017-10-13 123 views
1

我已经构建了Cordova App (cordova -v 7.0.1,cordova-android 6.1.0)。Cordova WebView的localStorage在Android 7中无法访问?

这包括自动启动。这意味着当定义,在应用程序,蓝牙设备连接到,应用程序将启动。

这是做的方法:

  1. 保存在localStorage的(file__0.localstorage)bluetooths地址.// JS侧
  2. 广播接收器,在bluetooth.device.action.ACL_CONNECTED。检索的localStorage(file__0.localstorage):如果我们的localStorage开始连接的设备匹配设备app.//机端

这是在2016年年底编制和它的工作直到现在,即使有更新,软件明智的,设备。

我决定做一些应用程序更新,现在它停止工作。经过一些调试后,我看到我无法读取file__0.localstorage。这是我到目前为止:

File dataDir = new File(context.getFilesDir().getParent()); 
    File appWebViewFilesDir = new File(dataDir, "app_webview/Local Storage/file__0.localstorage"); 

    Log.d(TAG, "Absolute path is " + appWebViewFilesDir.getAbsolutePath()); 
    //Result (rooted phone): path is given. 
    //Result (UNrooted phone): path is given. 

    Log.d(TAG, "Fine name is " + appWebViewFilesDir.getName()); 
    //Result (rooted phone): name is given. 
    //Result (UNrooted phone): name is given. 

    Log.d(TAG, "Is file Readable " + appWebViewFilesDir.canRead()); 
    //Result (rooted phone): true. 
    //Result (UNrooted phone): false. 

    Log.d(TAG, "Tring to set file to readable? " +appWebViewFilesDir.setReadable(true)); 
    //Result (rooted phone): true. 
    //Result (UNrooted phone): false. 

    Log.d(TAG, "Tring to set file to readable for all users? " + appWebViewFilesDir.setReadable(true, true)); 
    //Result (rooted phone): true. 
    //Result (UNrooted phone): false. 

    Log.d(TAG, "Is file Readable " + appWebViewFilesDir.canRead()); 
    //Result (rooted phone): true. 
    //Result (UNrooted phone): false. 

    Log.d(TAG, "Does this file exist " + appWebViewFilesDir.exists()); 
    //Result (rooted phone): true. 
    //Result (UNrooted phone): false. 

任何想法何时有此变化?

任何想法如何使localStorage file__0.localstorage可访问,而无需root设备?

有可能解决这个问题,而不必实施一个新的数据存储系统?

P.S.数据持久性在这种情况下并不重要。

回答

0

这不是一个真正的Android 7问题。 localstorage似乎取决于webview。而且webview可以独立升级。

可以解决这个问题,而无需实现一个新的数据 存储系统?

是的。 file__1.localstorage是一个SQLLite数据库。现在,在同一个文件夹app_webview/Local Storage中,您应该找到另一个文件夹leveldbLevelDB是由谷歌创建的数据库。例如,您可以使用java包装器leveldb-android来访问它。然后你应该使用迭代器遍历条目,寻找你需要的条目。在我的情况下调用get()返回null