【发布时间】:2018-03-25 13:28:51
【问题描述】:
我已经构建了一个 Cordova 应用程序 (cordova -v 7.0.1,cordova-android 6.1.0)。
这包括自动启动。这意味着当定义时,在应用程序中,蓝牙设备连接到,应用程序将启动。
这样做的方式:
- 将蓝牙地址保存在localStorage(file__0.localstorage).//JS端
- BroadcastReceiver,在 bluetooth.device.action.ACL_CONNECTED 上。如果连接的设备与我们的 LocalStorage Start 应用中的设备匹配,则检索 localStorage (file__0.localstorage)。// Native 端
这是在 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设备即可访问吗?
是否可以在不实施新的数据存储系统的情况下解决这个问题?
附:在这种情况下,数据持久性并不那么重要。
【问题讨论】:
标签: javascript android cordova local-storage