SQLite & Android

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
andyh1234
Posts: 442
Joined: Mon Aug 13, 2007 4:44 pm
Location: Eccles UK
Contact:

SQLite & Android

Post by andyh1234 » Mon Nov 14, 2011 5:15 pm

Im porting an iOS app I wrote at the moment that uses sqlite.

In the app I use the following commands...

In the preopen stack I use the following to get the path to the documents

put specialFolderPath("documents") into gPathToDocuments

When its time to open the database I call...

put gPathToDocuments & "progress.db" into dbPath
put revOpenDatabase ("sqlite",dbPath,,,,) into gProgressDBID

On iOS this works fine, if the file isnt found it is created, however on android the 2nd line here causes my App to stop, ie. anything after this line is not processed.

The dbPath always seems to be returned as '/progress.db' which seems wrong to me.

Whats the best way to get this working on android???

Thanks

Andy

Klaus
Posts: 13864
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: SQLite & Android

Post by Klaus » Mon Nov 14, 2011 5:32 pm

Hi Andy,

looks like you forgot to add a SLASH after the specialfolderpath!?
...
put specialFolderPath("documents") & "/" into gPathToDocuments
...


Best

Klaus

andyh1234
Posts: 442
Joined: Mon Aug 13, 2007 4:44 pm
Location: Eccles UK
Contact:

Re: SQLite & Android

Post by andyh1234 » Mon Nov 14, 2011 5:37 pm

Thanks Klaus,

Tried that but no change im afraid.

Its like the database location is not writeable? Is it possible to create a database on Android or can you only work with ones that are already there?

andyh1234
Posts: 442
Joined: Mon Aug 13, 2007 4:44 pm
Location: Eccles UK
Contact:

Re: SQLite & Android

Post by andyh1234 » Mon Nov 14, 2011 5:41 pm

Just to update this, the specific error returned after the db command is...

Database Error: Unable to open the database file.

This isnt surprising as there is no db file initially, on all other deployments including iOS the engine creates a database if one is not found, but it looks like this isnt happening which is why I was questioning the path, is '/' correct as this is what is being returned by specialfolderpath("documents")

andyh1234
Posts: 442
Joined: Mon Aug 13, 2007 4:44 pm
Location: Eccles UK
Contact:

Re: SQLite & Android

Post by andyh1234 » Mon Nov 14, 2011 6:00 pm

No idea why, but its just started working!

All I did was uncheck the Android build and did a test build in iOS, then went back and re-enabled the Android build in the standalone settings area and now it works too.

Klaus
Posts: 13864
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: SQLite & Android

Post by Klaus » Mon Nov 14, 2011 6:29 pm

Hi Andy,

glad you got it working.
Since I do not develop for Android, I can only be of general help.

And since ALL specialfolderpath(xyz) come with NO slash at the end, I'm sure this should be also the case on Android!
If there really IS A SLASH at the end on Android with specialfolderpath("documents") I consider this as a BUG for "conceptional continuity" sake :D


Best

Klaus

Post Reply

Return to “Android Deployment”