Page 1 of 1

Can't copy database [SOLVED]

Posted: Mon May 23, 2016 10:26 am
by MaxV
Hello,
I want to copy my database for backup purpose, but the following code doesn't work on Android, why?

########CODE#######
on mouseUp
#close database connection
put the connID of this stack into conID
revCloseDatabase conID
#backup
if the environment is "mobile" then
put URL ( "binfile:" & SpecialFolderPath("documents") & "/gamedb.sqlite" ) into URL ("binfile:" & the text of field "corrente" & "/gamedb.bak" )
else
#impostiamoci per lavorare con i percorsi relativi
set itemDel to "/"
set the defaultFolder to item 1 to -2 of (the effective fileName of this stack)
put URL ("binfile:" & the defaultfolder & "/gamedb.sqlite" ) into URL ("binfile:" & the text of field "corrente" & "/gamedb.bak" )
end if
#salviamo l'impostazione
answer "backup eseguito"
OpenStack #this is to reconnect to the database
go to card "principale"
end mouseUp
#####END OF CODE#####

Re: Can't copy database

Posted: Mon May 23, 2016 11:08 am
by dave.kilroy
Hi MaxV - sometimes when I use URL I need to make sure there are enough brackets to ensure that the engine parses the bits I want parsed first before parsing the rest ... it probably won't solve your issue, but it just might?

Code: Select all

put URL ( "binfile:" & (SpecialFolderPath("documents") & "/gamedb.sqlite" )) into URL ("binfile:" & (the text of field "corrente" & "/gamedb.bak" ))

--and

put URL ("binfile:" & (the defaultfolder & "/gamedb.sqlite" )) into URL ("binfile:" & (the text of field "corrente" & "/gamedb.bak" ))
EDIT: of course the other thing is, are you sure the location in field "corrente" is valid?

Re: Can't copy database

Posted: Tue May 24, 2016 10:06 pm
by MaxV
I fell so stupid... I had to check write external storage in the app permission.
I hate all this permission checks and requests for mobile app! :evil:

Re: Can't copy database [SOLVED]

Posted: Wed May 25, 2016 8:43 am
by dave.kilroy
I've done that exact same thing with permissions on Android - I bet we all have...