Android Question Cant Open Database Exception - Android 6.0

Douglas Farias

Expert
Licensed User
Longtime User
Hi all.
I see today on Google Play Console errors reported about open database

Errors like this
android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:207)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:191)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:806)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:791)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:669)
at anywheresoftware.b4a.sql.SQL.Initialize(SQL.java:37)
at leitor.df.texto.keyvaluestore._initialize(keyvaluestore.java:253)
at leitor.df.texto.main._activity_create(main.java:577)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at leitor.df.texto.main.afterFirstLayout(main.java:102)
at leitor.df.texto.main.access$000(main.java:17)
at leitor.df.texto.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
By Android 6.0 - Moto G (osprey_uds)


I m tryed to find any bug about this but i really dont found.
On my app i use the KeyValueStore Class without any modification V1.01.

https://www.b4x.com/android/forum/t...ple-and-efficient-key-value-data-store.26317/

Here is the code used on my app

B4X:
       'CRIA E DECLARA PASTA DO APLICATIVO
    If File.ExternalWritable Then
    Try
        target = File.DirRootExternal
        File.MakeDir(target, "textreader")
         FP = File.Combine(target,"textreader")
        File.MakeDir(target, "text")
        fptextos = File.Combine(target,"text")
    Catch
        target = File.DirDefaultExternal
        File.MakeDir(target, "textreader")
         FP = File.Combine(target,"textreader")
        File.MakeDir(target, "text")
        fptextos = File.Combine(target,"text")
    End Try
    Else
        target = File.DirInternal
        File.MakeDir(target, "textreader")
         FP = File.Combine(target,"textreader")
        File.MakeDir(target, "text")
        fptextos = File.Combine(target,"text")
    End If
  
  
    'CRIA OU INICIA O BANCO DE DADOS SQLITE
    kv.Initialize(FP, "data")

The kv its the KeyValueStore db
Note: I m not using dirassets.

Here its my manifest
AddManifestText(
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="23" />
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")

SetActivityAttribute(main, android:windowSoftInputMode, adjustResize|stateHidden)

AddPermission(android.permission.INTERNET)
AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)
RemovePermission(android.permission.READ_LOGS)
SetApplicationAttribute(android:largeHeap,"true")

AddApplicationText(
<meta-data android:name="com.google.android.gms.version"
android:value="@Integer/google_play_services_version"/>
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
)

I really dont know where its the error, i dont use any other db, only keyvaluestore
Someone know errors like this on KeyvalueStore class?


Thx
 
Last edited:

Douglas Farias

Expert
Licensed User
Longtime User
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

kurarisu_kitsune

New Member
Hi, i am a newbie. And I have the same error. I have read some threads saying that I should copy my database file from DirAssets to DirInternal. How can i do that in my android phone? Thank you so much.

-This is for our thesis. <3
 
Upvote 0
Top