sqlite corrupted when copied

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

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
paulalsmith1000
Posts: 29
Joined: Sat Jun 15, 2019 10:09 am

sqlite corrupted when copied

Post by paulalsmith1000 » Thu Aug 29, 2019 11:28 pm

Dear Everyone

Could anyone tell me why my sqlite db file gets corrupted when I copy it?

The DB is located in the special folder documents for the app, I would then like to copy it to the special folder external documents at the end of the app / as it closes (which is the folder that a google drive app watches and syncs)

If I change the original location of the DB to external documents its fine, but if I try and copy it, it gets corrupted.

I've tried copying other things and they are also fine, just not the DB.

I think possibly its because there are open connections to the database at the time I'm trying to copy it, maybe?

Could someone tell me the simplest way to make sure all the connections are closed / whether this could be the problem / or what else it might be?

I have been using the put URL command btw.

As ever, any help very much appreciated.

Kind regards

Paul

SparkOut
Posts: 2027
Joined: Sun Sep 23, 2007 4:58 pm

Re: sqlite corrupted when copied

Post by SparkOut » Thu Aug 29, 2019 11:54 pm

What's the complete "put url" command you are using?
I think it sounds like your problem might just maybe perhaps be solved if you use "binfile:" instead of "file:" in the put url command? Potentially.

paulalsmith1000
Posts: 29
Joined: Sat Jun 15, 2019 10:09 am

Re: sqlite corrupted when copied

Post by paulalsmith1000 » Fri Aug 30, 2019 8:02 pm

Hi SparkOut

This is the code:-

command save_db_external
create folder specialFolderPath("external documents") & "/" & "upload folder"
put URL("file:" & specialFolderPath("external documents") & tdbname) into URL("file:" & specialFolderPath("external documents") & "/" & "upload folder" & tdbname)
end save_db_external

Thanks v much, I'll try what you suggest, what does the 'bin' bit mean btw?

Kind regards

Paul

SparkOut
Posts: 2027
Joined: Sun Sep 23, 2007 4:58 pm

Re: sqlite corrupted when copied

Post by SparkOut » Fri Aug 30, 2019 9:06 pm

"binfile:" is telling the engine to write the binary data file faithfully byte for byte.

"file:" is telling the engine to write a text file, where the engine will interpret the line endings and match to the current platform's convention.

Every time you need a binary faithful storage or retrieval, "binfile:" is what you need.

Also, it looks like you need an extra slash between "upload folder" and tdbname

Post Reply

Return to “Android Deployment”