Android Question Problem with Android 5

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
Hi,
My app can backup the db to the DirRootexternal and restore it to Dirinternal.
All works ok in Android 4
In Android 5 Im having a problem, this is the code:

B4X:
            If File.Exists(File.DirRootExternal&"/armi.portit.backcup", "portit.db")=True Then
                StopService(LeeWebDelay)
                Try
                    File.Copy(File.DirRootExternal&"/armi.portit.backcup", "portit.db", File.DirInternal, "portit.db")
                    'File.Copy(File.DirDefaultExternal, "Params", File.DirInternal, "Params")
                    sql1.ExecNonQuery("INSERT INTO logevent VALUES('"&DateTime.now&"','mAjustes',0,'Restoring from  SD')")
                Catch
                    Msgbox("Error restoring.","Atention!")
                End Try   
            Else
                Msgbox("There's no backup.","Atention!")
            End If

I catch the error "Error restoring" but the db restore is made OK.
Then I thought the Error comes from the sql insert, how can I catch this and know which is the error.
It works ok in Android 4, same app in Android 5 fails.
Thanks
 

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
FWIW
I split the try cath in two, one for the copy and one for the sql insert.
The error is because the copy disconects the database or make it read only, I dont know.
In Android 4 the INSERT is not done but theres no error at all.
In Android 5 the error is detected ok, see atached image.
 

Attachments

  • 11844230_1108506415846116_153596762_n.jpg
    11844230_1108506415846116_153596762_n.jpg
    39.3 KB · Views: 142
Upvote 0
Top