sqlite on android
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 43
- Joined: Tue Apr 08, 2008 9:56 pm
- Location: Purdue University
sqlite on android
Hi all,
recently finished developing my first iphone app, and now I'm adapting it for android. everything works perfectly in the iphone version. The app uses a sqlite db that is copied over in the copy files to specialFolderPath("engine"). When I try to connect to the db on android, I get an error I was unable to connect to the database. "Database Error: Unable to open the database file".
I verified that the file is properly copying by setting the defaultfolder to specialFolderPath("engine") and putting the files. The database is there I just can't connect to it.
I made sure to check "sqlite" in the standalone settings!
Not sure what else to do. Thoughts?
recently finished developing my first iphone app, and now I'm adapting it for android. everything works perfectly in the iphone version. The app uses a sqlite db that is copied over in the copy files to specialFolderPath("engine"). When I try to connect to the db on android, I get an error I was unable to connect to the database. "Database Error: Unable to open the database file".
I verified that the file is properly copying by setting the defaultfolder to specialFolderPath("engine") and putting the files. The database is there I just can't connect to it.
I made sure to check "sqlite" in the standalone settings!
Not sure what else to do. Thoughts?
Re: sqlite on android
Hi,
What is the exact path to the database? Often, having characters like ()-/: and probably a few others cause such problems on Android. Another possibility is that it wants to be able to make changes to the database but lacks write permission. Copying to the documents folder might help in that case.
Kind regards,
Mark
What is the exact path to the database? Often, having characters like ()-/: and probably a few others cause such problems on Android. Another possibility is that it wants to be able to make changes to the database but lacks write permission. Copying to the documents folder might help in that case.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: sqlite on android
Hi grimaldiface,
I may repeat myself, but the SEARCH function here in the forum isn't really THAT bad!
Check this: http://forums.livecode.com/viewtopic.ph ... 16#p114411
Best
Klaus
I may repeat myself, but the SEARCH function here in the forum isn't really THAT bad!
Check this: http://forums.livecode.com/viewtopic.ph ... 16#p114411
Best
Klaus
-
- Posts: 43
- Joined: Tue Apr 08, 2008 9:56 pm
- Location: Purdue University
Re: sqlite on android
Right now I am using the following code to connect to the db. Only trying to connect at this point, not write changes.Mark wrote:Hi,
What is the exact path to the database? Often, having characters like ()-/: and probably a few others cause such problems on Android. Another possibility is that it wants to be able to make changes to the database but lacks write permission. Copying to the documents folder might help in that case.
Kind regards,
Mark
The code I use in my working iPhone version is this...
Code: Select all
if environment() is "mobile" then
set the defaultfolder to specialFolderPath("engine")
else
set the defaultfolder to the desktop folder
end if
put revOpenDatabase("sqlite", "strategyDB.sqlite") into tDatabaseID
Code: Select all
if environment() is "mobile" then
put specialfolderpath("engine") & "/strategyDB.sqlite" into tDBFile
put revopendatabase("sqlite",tDBFile) into tDatabaseID
end if
Re: sqlite on android
It definitively shouldn't work on iOS either!grimaldiface wrote:Not sure why this works on iOS but not android....
Why not take a look at the link I provided?
-
- Posts: 43
- Joined: Tue Apr 08, 2008 9:56 pm
- Location: Purdue University
Re: sqlite on android
Klaus wrote:It definitively shouldn't work on iOS either!grimaldiface wrote:Not sure why this works on iOS but not android....
Why not take a look at the link I provided?
Klaus--
Thanks. I did read the thread you provided prior to posting this one. You're right, the search isn't THAT bad (but it's still pretty bad!).
I guess I'm not seeing the answer to my problem in that thread--care to help me out? What I don't understand is that you mention I need write privileges for the engine folder? I don't understand why, if I'm not writing anything to the folder, just reading. Maybe I there's something about accessing a database that I don't understand.....
Edit: I'll try copying to documents folder later this evening. But I'm still interested to learn why this isn't working...
Re: sqlite on android
Hi Grimadliface,
see it this way:
The ENGINE folder is TABOO, noone is allowed to write here!
I'm not sure about the actual technical background, but I think opening a database prepares
the db file to be read AND written to and this is prohibited in any case!
Therefore you need to copy it to the users DOCUMENTS folder where we have full access!
Best
Klaus
see it this way:
The ENGINE folder is TABOO, noone is allowed to write here!
I'm not sure about the actual technical background, but I think opening a database prepares
the db file to be read AND written to and this is prohibited in any case!
Therefore you need to copy it to the users DOCUMENTS folder where we have full access!
Best
Klaus
-
- Posts: 43
- Joined: Tue Apr 08, 2008 9:56 pm
- Location: Purdue University
Re: sqlite on android
Sure enough, moving the db to the DOCUMENTS folder solved the problem. There's definitely some difference between iOS and Android here, because I was definitely able to access the db from the ENGINE on iOS. Nevertheless, seems the best course is to just avoid working from the ENGINE altogether. Thanks!Klaus wrote:Hi Grimadliface,
see it this way:
The ENGINE folder is TABOO, noone is allowed to write here!
I'm not sure about the actual technical background, but I think opening a database prepares
the db file to be read AND written to and this is prohibited in any case!
Therefore you need to copy it to the users DOCUMENTS folder where we have full access!
Best
Klaus
-
- Posts: 50
- Joined: Mon Mar 03, 2014 1:17 am
Re: sqlite on android
Howdy,
Belatedly, I can confirm this is indeed a key difference between iOS and Android. I built an app using SQLite. The database resides in the engine on iOS and works fine. But it didn't work on Android. When I moved the SQLite database to documents, it worked immediately. Thanks for solving this problem!
Sean
Belatedly, I can confirm this is indeed a key difference between iOS and Android. I built an app using SQLite. The database resides in the engine on iOS and works fine. But it didn't work on Android. When I moved the SQLite database to documents, it worked immediately. Thanks for solving this problem!
Sean
-
- Posts: 746
- Joined: Sun Feb 04, 2007 11:01 pm
- Location: McKenna, WA
Re: sqlite on android
Here's how I handle this.
Code: Select all
if the environment is not "mobile" then exit preOpenStack
put specialFolderPath("documents") & “/MyDataBase.sqlite" into tDatabaseFile
if there is not a file tDatabaseFile then
put url("binfile:" & specialFolderPath("engine") & "/MyDataBase.sqlite") into url("binfile:" & specialFolderPath("documents") & "/MyDataBase.sqlite")
else
-- answer "There is a file MyDataBase.sqlite"
end if
Tom
MacBook Pro OS Mojave 10.14
MacBook Pro OS Mojave 10.14