Android Question Could not open the database in read/write mode

hatzisn

Expert
Licensed User
Longtime User
Hi everyone,

I tried today to install an app I made that uses the new DBUtils module as published by Erel in an Android 7 device and it worked perfectly. When I tried it to install it in an android 4.2.2 device I got the following error:

"Could not open the database in read/write mode"

I discovered that if I change the GetDBFolder of the DBUtils module into this everything works fine in both devices:

B4X:
Public Sub GetDBFolder As String
#If B4A
    Dim pid As Phone
    Dim rp As RuntimePermissions
    If File.ExternalWritable Then
        If pid.SdkVersion >= 23 Then
            Return rp.GetSafeDirDefaultExternal("")
        Else
            Return File.DirDefaultExternal
        End If
    Else
        Return File.DirInternal
    End If
#Else If B4i
    Return File.DirDocuments
#End If
End Sub

Just wanted to share this. I hope it will be helpful to someone facing the same error. Maybe Erel you would like to inform us about this difference bettween rp.GetSafeDirDefaultExternal("") and File.DirDefaultExternal in before 23 APIs.

Cheers
 

hatzisn

Expert
Licensed User
Longtime User
Once again you were right. You should consider turning yourself from a programmer to an oracle... :)
 
Upvote 0
Top