2017-10-13 1 views
1

나는 코도 바 응용 프로그램 (cordova -v 7.0.1, cordova-android 6.1.0)을 빌드했습니다.Android 7에서 Cordova WebView의 localStorage에 액세스 할 수 없습니까?

여기에는 자동 시작 기능이 포함되어 있습니다. 즉, 앱에서 블루투스 장치가 연결되면 앱이 시작됩니다.

이 이루어졌다 방법 : 로컬 스토리지 (file__0.localstorage)에

  1. 저장 bluetooths 주소 .// JS 측에 bluetooth.device.action.ACL_CONNECTED
  2. 브로드 캐스트 리시버. 우리의 로컬 저장 시작에 연결된 장치 일치하는 장치가 기본 측

이는 2016 년 말에 컴파일 그리고 심지어 새와 함께, 지금은 때까지 일했다, 현명한 소프트웨어를 app.// 경우 로컬 스토리지 (file__0.localstorage)를 검색, 장치.

앱 업데이트를하기로 결정했는데 이제는 작동이 멈췄습니다. 일부 디버깅 후 나는 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. 

어떤 아이디어가 있습니까?

어떤 아이디어를 어떻게 장치를 루트하지 않고도 file__0.localstorage localStorage에 액세스 할 수 있습니까?

새로운 데이터 스토리지 시스템을 구현하지 않고도이를 해결할 수 있습니까?

P. 이 경우 데이터 지속성이 중요하지 않습니다.

답변

0

Android 7 문제가 아닙니다. localstorage는 webview에 의존하는 것 같습니다. 그리고 웹뷰는 독립적으로 업그레이드 될 수 있습니다.

새로운 데이터를 구현하지 않고도이를 해결할 수 있습니까? 스토리지 시스템?

예. file__1.localstorage는 SQLLite db였습니다. 이제 동일한 폴더에 app_webview/Local Storage이 있으면 다른 폴더 leveldb을 찾아야합니다. LevelDB은 Google에서 만든 데이터베이스입니다. 예를 들어 leveldb-android Java 랩퍼를 사용하여 액세스 할 수 있습니다. 그런 다음 반복자를 사용하여 항목을 반복하여 필요한 항목을 찾아야합니다. 내 경우에는 을 호출하면 null가 반환되었습니다.

관련 문제