Android Question Error: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not o

DavideV

Active Member
Licensed User
Longtime User
Hi, i've got the error:

android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database

from one of my apps (and maybe some other users didn't send the log).
The app uses the KeyValueStore 2 class and the device is an android 4.4 (unknown brand)

I found that the most common cause is the directory used to store the SQL and that using dirinternal for it should solve the problem.

Anyway I'm using this code thinking it was correct (in Starter module):
B4X:
Sub Process_Globals
    Public  Rtp         As RuntimePermissions
    Public  Kvs         As KeyValueStore
    'common to activities
    Public WorkingDir            As String            'directory used to store app data
    ...

Sub Service_Create
'create the working  directory If doesn't exist...
    Dim Dir As String=Rtp.GetSafeDirDefaultExternal("")     'safe directory device dependent
    Kvs.Initialize(Dir, "manager")                            'init keyvaluestore
   WorkingDir=File.Combine(Dir,"screenlock")
    ...

'manifest:
'add permission for sdk up to 18 for the external storage
AddManifestText(
<uses-permission
  android:name="android.permission.WRITE_EXTERNAL_STORAGE"
  android:maxSdkVersion="18" />)

I would like to know if it is correct before modify and republish the app..

Thanks in advance
Davide
 
Top