Can't copy database [SOLVED]

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Can't copy database [SOLVED]

Post by MaxV » Mon May 23, 2016 10:26 am

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#####
Last edited by MaxV on Tue May 24, 2016 10:07 pm, edited 1 time in total.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: Can't copy database

Post by dave.kilroy » Mon May 23, 2016 11:08 am

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?
"...this is not the code you are looking for..."

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Can't copy database

Post by MaxV » Tue May 24, 2016 10:06 pm

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:
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: Can't copy database [SOLVED]

Post by dave.kilroy » Wed May 25, 2016 8:43 am

I've done that exact same thing with permissions on Android - I bet we all have...
"...this is not the code you are looking for..."

Post Reply