Creating Apps for use on Android mobile phones

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: Creating Apps for use on Android mobile phones

Post by AxWald » Sun May 03, 2020 11:47 am

Ooops, forgot:

Jacqueline provided some nice infos for mobile debugging some time ago, and this gave me some ideas. So I'll provide my basic Android debugging tools here. They are raw, buggy & unpolished, but nevertheless they have proven quite useful rather often ;-)

Put this into your stack script:

Code: Select all

global gScript, gPath

--  Android debug handlers  --  this part in stack script!
--  The basics are by Jacqueline Landman Gay | jacque at hyperactivesw dot com
--  Source: http://www.hyperactivesw.com/resources_mobiledebugging.html
--  axwald @ forums.livecode.com

--  global gScript must be declared!

on log pText
   answer pText
end log

on errorDialog pErr
   log "   ===   ERROR:   ===   " & CR & pErr
end errorDialog

--  Additions to android debug by axwald:
--  needed: button "do_btn" & its script!

on hCl  --  clears the cmd hist
   put empty into gScript
end hCl

on h  --  a basic command history (h for "h"istory ...)
   if the environment = "mobile" then
      mobilepick gScript,1,"cancel"                   --  show the cmd hist for selection
      if the result is not 0 then
         send "DoIt" && the result to btn "Do_btn"  --  and send the selection to the button
      end if
   else
      answer information "This requires a mobile device ..."  --  too lazy to implent for desktop ...
   end if
end h

on DF what
   --  shows information for 'the specialFolderPath's;
   --  sets the DefaultFolder (hence the name ...) to a certain location,
   --  and displays path, files and folders for this.
   --  Comes handy to find your files ;-)
   --  Using the form 'DF "/path/to/anywahere"' you can explore the whole filesystem
   --  (Be sure to quote your paths then, and to omit the trailing slash!)
   if (what = "?") OR (what = "man") then                           --  Help
      answer "Check those folders contents:" & CR & CR & \
            "C = Cache; D = Documents;" & CR & \
            "E = Engine; ( F = Fonts; S = Sounds; )" & CR & \
            "H = Home; R = Resources; T = Temporary" & CR & \
            quote & "/mnt" & quote & " = /mnt/ => any path (quote path, omit ending slash!)." & CR & CR & \
            "(Type " & quote & "DF " & quote & " & the part before '=' !)" titled " man DF" 
      exit DF
      
   else if what = "C" then                                          --  switch modes
      put "Cache" into myVar
      set the defaultfolder to specialfolderPath("cache") & slash      
   else if what = "D" then
      put "Documents" into myVar
      set the defaultfolder to specialfolderPath("documents") & slash
   else if what = "E" then
      put "Engine" into myVar
      set the defaultfolder to specialfolderPath("engine") & slash
   else if what = "F" then
      put "Fonts" into myVar
      set the defaultfolder to specialfolderPath("engine") & "/fonts/"
   else if what = "S" then
      put "Sounds" into myVar
      set the defaultfolder to specialfolderPath("engine") & "/sounds/"
   else if what = "H" then
      put "Home" into myVar
      set the defaultfolder to specialfolderPath("home") & slash
   else if what = "R" then
      put "Resources" into myVar
      set the defaultfolder to specialfolderPath("resources") & slash
   else if what = "T" then
      put "Temporary" into myVar
      set the defaultfolder to specialfolderPath("temporary") & slash
   else
      put "Custom Path" into myVar
      set the defaultfolder to what & slash
   end if
   
   put the result into myRes
   if myRes is not empty then                                         --  check for errors
      put  "_CAUTION: the Result:" & CR & myRes & CR & CR into myRes
   end if
   
   put myRes & "_Mode: " & what & " | " & myVar & CR & \              --  build result data
   "_Path resulting: " & CR & the defaultfolder & CR & CR & \
         "_Files: ==========" & CR & the files & CR & CR & \
         "_Folders: ==========" & CR & the folders & CR & CR & "_DF is resetted!" into myMsg
   if not the environment = "mobile" then
      set the clipboarddata["text"] to myMsg                          --  choose output mode
   end if
   set the defaultfolder to gPath
   log myMsg                                                          --  and use it
end DF
Then make a button (you may have it invisible later ...) "do_btn", and set it's script:

Code: Select all

global gScript

--  android debugging handlers - this lives in your debugger button!
on mouseUp
  DoIt
end mouseUp

on DoIt what
   if what is not empty then                       --  it's called by "on h"/ stack script
      put line what of gScript into myPrompt
   else                                            --  user found this button
      put "h" into myPrompt
   end if
   ask "What shall I do?" & CR & "- 'log [param]' = 'answer/ put';   Expl: 'log the screenrect';" & CR & \
         "- 'DF ?' = help for the 'specialFolder checker';" & CR & \
         "On mobile only:" & CR & \
         "- 'h' = use a basic command history;" & CR & \
         "- 'hCl' = clears this cmd hist." with myPrompt titled "Debug helper"
   if it is not empty then                         --  we got the new command
      if gScript is empty then
         put it into gScript
      else                                         --  store it
         put CR & it after gScript
         sort lines of gScript
         gSClear
      end if
      try
         do it                                        --  and execute it
      catch theError
         answer "Couldn't execute this command:" & CR & "     do " & it & CR & \
         "Error received:" & CR & theError titled "This didn't work:" 
      end try
   end if
end DoIt

on gSClear                    --  removes duplicate lines in the cmd hist
   put gScript into MyVar
   repeat with i = 1 to the number of lines of myVar
      if line i+1 of myVar = line i of myVar then
         delete line i+1 of myVar
      end if
      if line i of myVar is empty then exit repeat
   end repeat
   put myVar into gScript
end gSClear
This uses the answer dialog to give you access to a basic command line. Hit the button for input & a basic help.
  • "DF ?" (DefaultFolderstuff ...) gives you an overview for the "FolderList" options. "DF d" for instance lists your documents folder. You may use this to check the whole Android file system ;-)
  • "log" is a shortcut for "answer" - "log the screenrect" = "answer the screenrect". Use this to get the value of variables and properties (log the textstyle of fld head_fld) ...
  • "h" gives you a history of the commands you have used in this session, sorted alphabetically, dupes removed.
    Use it to select an old command & modify it (log the textstyle^^^^^^font of fld head_fld) ...
  • Feel free to add custom commands - just add a handler in the stack script.
Hope this helps someone. Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

Dragondos2020
Posts: 29
Joined: Mon Apr 20, 2020 1:00 pm

Re: Creating Apps for use on Android mobile phones

Post by Dragondos2020 » Sun May 03, 2020 1:19 pm

Hi AxWald. Do appreciate your persistence in trying to resolve this for me. OK. Moving forward:

(1) I can confirm that membershipdatabase.db has a table called members. It also contains six separate records for testing.
(2) membershipdatabase.db has been copied to 'copy files' in the standalone settings.
(3) the openStack script has been replaced with your coding
(4) A New Button has been added to the stack and your code added

Tested in the LiveCode Environment and all is good.

Tested within the emulator, with the following results:

The first message displayed:
SFP Resources, Files
membershipdatabase.db
british isles.png
resetfees.txt

Second message displayed:
There is a DB in Resources?
True

Third message displayed:
There is a DB in Document?
True

Fourth message displayed:
SFP Documents, File:
membershipdatabase.db

I then selected the 'Login' Button (which just moves the program from the first card to the next). At this stage a message appeared stating "There was a problem accessing the Database: revdberr, Database Error: no such table: members" This is an error check that I included in my code. So at this point, I would normally expect the Datagrid to be populated with the six test records held in the Database. The Datagrid is empty.

I then selected the New Button that you suggested I added to the stack. Two messages were displayed. The first "There is a DB in Documents? True" and the second message: "Query Failed: revdberr, Database Error: no such table: members SELECT * FROM 'members' LIMIT 1;"

I really hope that the above results helps in your 'Detective work'.

Thanks again. I really do not know where to turn.

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: Creating Apps for use on Android mobile phones

Post by AxWald » Sun May 03, 2020 2:49 pm

Ooops.

"membershipdatabase.db"? This doesn't look like SQLite. What's that?
AFAIK it's a generic extension that can contain anything - what connection type you're using?

I just assumed you'd use SQLite - local on Android it seemed obvious ...
If it's actually a SQLite try to rename it to "membershipdatabase.sqlite" - maybe that helps.

Good luck!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

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

Re: Creating Apps for use on Android mobile phones

Post by Klaus » Sun May 03, 2020 4:43 pm

I can assure that the suffix .DB works very fine with SQLite, been using it for years, even on mobile.
So this is definitively not the problem! You can even omit any suffix, as long as you provide a valid SQLite file everything will work!

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Creating Apps for use on Android mobile phones

Post by sphere » Sun May 03, 2020 5:11 pm

I was reading the thread and of course Klaus beat me 8) , as i was thinking there must be something with the place where the database file is residing...

In fact you don't need to copy an existing db file, you may if you wish, but if it is not necessary and an app can start from scratch:
first i check if the db exists:

Code: Select all

on openCard
   ---------check db existence for order history, password and user details---------
   put specialFolderPath("documents") & "/mobile.app" into tDBexist
   if there is not a file tDBexist then
      dbCreate
      wait 50 milliseconds --give it a bit of time, i noticed when going to fast it doesn't work ok
      -----1e standaard insert------------
      send"insfirstrowdb" to me in 1 tick
      -----------------------
      wait 50 milliseconds
      readDB  
   else
      readDB
   end if
if it needs to be created:

Code: Select all

on dbCreate
   local tSQL, tFields
   put specialFolderPath("documents") & "/mobile.app" into gCustHistDBPath
   put revOpenDatabase("sqlite", gCustHistDBPath, , , , ) into gLocalDbID
   --answer gLocalDbID titled"globaldbid"
   # create table HISTORIE
   put "CREATE TABLE history (id INTEGER PRIMARY KEY AUTOINCREMENT, datumtijd TEXT, shopname TEXT, categorie TEXT, product TEXT, prijs DECIMAL(5,2), ophbez TEXT)" into tSQL 
   revExecuteSQL gLocalDbID, tSQL
   --answer the result titled"setting table"
   ------------------------
   # create password table 
   put "CREATE TABLE pw (id INTEGER PRIMARY KEY, startpass TEXT)" into tSQL
   revExecuteSQL gLocalDbID, tSQL
   ----------------------------
   # create customerdetails table
   put "CREATE TABLE cust (id INTEGER PRIMARY KEY, naam TEXT, telnr TEXT, email TEXT, straat TEXT, huisnr TEXT, toev TEXT, postcode TEXT, plaats TEXT, longtitude DECIMAL(10,7), latitude DECIMAL(10,7))" into tSQL 
   revExecuteSQL gLocalDbID, tSQL
   ----------------------
end dbCreate
then i do a first insert, only id is enough

Code: Select all

on insfirstrowdb
   --answer "insert first row"
   local tSQL, tFields,tD
   --first row history
   put 1 into tD
   put "id" into tFields
   put "INSERT INTO history (" & tFields & ") VALUES (:1)" into tSQL
   revExecuteSQL gLocalDbID, tSQL, "tD"
   --answer the result titled"insert hist"
   -------------------------
   ---first pw
   put 1 into tD
   put "id" into tFields
   put "INSERT INTO pw (" & tFields & ") VALUES (:1)" into tSQL
   revExecuteSQL gLocalDbID, tSQL, "tD"
   --answer the result titled"insert pw"
   -----------
   -----first cust----
   put 1 into tD
   put "id" into tFields
   put "INSERT INTO cust (" & tFields & ") VALUES (:1)" into tSQL
   revExecuteSQL gLocalDbID, tSQL, "tD"
   --answer the result titled"insert cust"
   --------------------
end insfirstrowdb
read it and do something with it(of course after your user has saved the data for the first time):

Code: Select all

on readDB
   local tSQL,tData
   ----documents is ok for Android and iOs-----------
   put specialFolderPath("documents") & "/mobile.app" into gCustHistDBPath
   put revOpenDatabase("sqlite", gCustHistDBPath, , , , ) into gLocalDbID
   put "SELECT startpass FROM pw WHERE id=1" into tSQL
   put revDataFromQuery(tab,return,gLocalDbID,tSQL) into tData --do something with the data
   ----delete char 1 of tData ---b weghalen die ervoor is gezet bij wegschrijven --this is for data(encrypted)
  -- put base64decode(tData) into gPwRecords
end readDB

Dragondos2020
Posts: 29
Joined: Mon Apr 20, 2020 1:00 pm

Re: Creating Apps for use on Android mobile phones

Post by Dragondos2020 » Sun May 03, 2020 6:29 pm

Hi Sphere

I must admit, your suggestions are looking good. I just need to spend a little time getting my head around your coding and what is happening.

I am going to amend my coding to follow your suggestions and provide an outlet so that I can recall and see the data initially created and then ensure my routines can work with that to save, amend, delete records etc.

Thank you for your help.

I will come back and give you an update on progress, which I sincerely hope will be positive. I am now about to get ready for a family quiz night. Not physically of course, but via zoom thanks to CoronaVirus.

Stay Well and Safe.
Regards

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Creating Apps for use on Android mobile phones

Post by sphere » Sun May 03, 2020 6:51 pm

The handlers are on my stack script and the Opencard is on my first card which also happens to be used as flash/intro/startup card, and then I switch to the first card where something is happening.
This is what I actually use on an working app.
So hope this works for you too.

Have fun with your family and stay safe too :)

Dragondos2020
Posts: 29
Joined: Mon Apr 20, 2020 1:00 pm

Re: Creating Apps for use on Android mobile phones

Post by Dragondos2020 » Mon May 04, 2020 10:59 am

There must definitely be a problem within my script. I have made so many different amendments that I am slightly loosing the thought process. I can easily track (watch) each step of the process whilst in the run mode in the LiveCode Environment. But I donot know how to track (watch) each step when running within the emulator or on my Android Phone, without putting popup messages at every single stage.



Looking at the different code: I use the 'connectToDB' routine -- Located in the stack

Code: Select all

on connectToDB
   local tDatabasePath, tDatabaseID, tSourceFile
   
   -- Check if we are in the IDE:
   if the environment = "development" then
      put specialFolderPath("resources") & "/membershipdatabase.db" into tDatabasePath
      -- Folder where the stack is in, we may write here in the IDE!
   else
      -- Runtime:
      ## put specialFolderPath("documents") & "/membershipdatabase.db" into -> tDatabaseID
      put specialFolderPath("documents") & "/membershipdatabase.db" into tDatabasePath
   end if
   
   -- Now check if the app has started the very first time but only as the final
   -- runtime because of our check above!
   if there is NOT a file tDatabasePath then
      put specialFolderPath("resources") & "/membershipdatabase.db" into tSourceFile
      put URL("binfile:" & tSourceFile) into URL("binfile:" & tDatabasePath)
   end if
   
   -- Green Light, File Present, Ready to Connect
   put revOpenDatabase("sqlite", tDatabasePath,,,,) into tDatabaseID
   if tDatabaseID is "" then
      answer warning "There was a problem accessing the Membership Database!"
   end if
   // put "membershipdatabase.db" into tDatabasePath
   setDatabaseID tDatabaseID
end connectToDB
And in the card stack:

Code: Select all

global gConnID, gLocalDbID

on openCard
   ---------check db existence for order history, password and user details---------
   put specialFolderPath("documents") & "/membershipdatabase.db" into tDBexist
   if there is not a file tDBexist then
      dbCreate
      wait 50 milliseconds --give it a bit of time, i noticed when going to fast it doesn't work ok
      -----1e standaard insert------------
      send"insfirstrowdb" to me in 1 tick
      -----------------------
      wait 50 milliseconds
      readDB  
   else
      readDB
   end if
end openCard


on dbCreate
   local tSQL, tFields
   put specialFolderPath("documents") & "/membershipdatabase.db" into gCustHistDBPath
   put revOpenDatabase("sqlite", gCustHistDBPath, , , , ) into gLocalDbID
   --answer gLocalDbID titled"globaldbid"
   # create table HISTORIE
   put "CREATE TABLE history (id INTEGER PRIMARY KEY AUTOINCREMENT, membertype TEXT, fee DECIMAL(2))" into tSQL 
   revExecuteSQL gLocalDbID, tSQL
   --answer the result titled"setting table"
   ------------------------
   # create password table 
   put "CREATE TABLE pw (id INTEGER PRIMARY KEY, startpass TEXT)" into tSQL
   revExecuteSQL gLocalDbID, tSQL
   ----------------------------
   # create customerdetails table
   put "CREATE TABLE members (member_id INTEGER PRIMARY KEY, fname TEXT, lname TEXT, addr1 TEXT, addr2 TEXT, addr3 TEXT, addr4 TEXT, postcode TEXT, joindate TEXT, fee DECIMAL(2), paid TEXT, membership TEXT, phone TEXT, mobile TEXT, email TEXT)" into tSQL 
   revExecuteSQL gLocalDbID, tSQL
   ----------------------
   put gLocalDbID into gConnID
end dbCreate

on insfirstrowdb
   --answer "insert first row"
   local tSQL, tFields, tD
   --first row history
   put 1 into tD
   put "id" into tFields
   put "INSERT INTO history (" & tFields & ") VALUES (:1)" into tSQL
   revExecuteSQL gLocalDbID, tSQL, "tD"
   answer the result titled "insert hist"
   
   ---first pw
   put 1 into tD
   put "id" into tFields
   put "INSERT INTO pw (" & tFields & ") VALUES (:1)" into tSQL
   revExecuteSQL gLocalDbID, tSQL, "tD"
   answer the result titled "insert pw"
   
   -----first cust----
   put 1 into tD
   put "member_id" into tFields
   put "INSERT INTO members (" & tFields & ") VALUES (:1)" into tSQL
   revExecuteSQL gLocalDbID, tSQL, "tD"
   answer the result titled "insert cust"
   --------------------
   put gLocalDbID into gConnID
end insfirstrowdb

on readDB
   local tSQL,tData
   ----documents is ok for Android and iOs-----------
   put specialFolderPath("documents") & "/membershipdatabase.db" into gCustHistDBPath
   put revOpenDatabase("sqlite", gCustHistDBPath, , , , ) into gLocalDbID
   put "SELECT startpass FROM pw WHERE id=1" into tSQL
   put revDataFromQuery(tab,return,gLocalDbID,tSQL) into tData --do something with the data
   
   show group "dgMembersList" on card "Members"
   set the dgText of group "dgMembersList" on card "Members" to tData
   put gLocalDbID into gConnID
end readDB
The code within the card stack does seem to work fine on initial start up, but when I go to save my record it does not appear to look for the database created by the above code. So it responds with No such table: members. Is there a way that I can track (watch) the process step by step when using the Emulator so that I can at least see what is going on and hopefully identify the problem.

I do not have the experience or knowledge to foresee what is happening. I need to watch the process step by step. This is the way I learn and understand.

Again, I call upon your generosity, and ask for guidance.

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Creating Apps for use on Android mobile phones

Post by sphere » Mon May 04, 2020 11:18 am

instead of answer you could use mobileToast, it's non-blocking, you need to include it with the inclusions.
then

Code: Select all

if the platform is "android" then
      mobileToast the Result, "long" --or short
      end if
so now you check if there is not a file, in the handler where you check if there is a file when you restart the app on your phone/emulator put a mobileToast to see if the file is there
if there is a file and is does not have the table, you know a thing more

Dragondos2020
Posts: 29
Joined: Mon Apr 20, 2020 1:00 pm

Re: Creating Apps for use on Android mobile phones

Post by Dragondos2020 » Mon May 04, 2020 3:22 pm

Hi Everyone who has taken time out to get me up and running with my coding problem for using my project on an Android Mobile Phone. You have taken serious time out to provide me with many options and possible solutions.

Unfortunately, I am still unable to resolve the last main problem of being able to save data, amend data and delete data (records) from a SQLite database. Where the database is being stored is not so obvious and I do not have the means or software to find out by searching my phone. However, we have come a long way in educating me in the process. For which I sincerely thank you all for.

I feel that the time has come for me to take the front seat and try and put everything together and see if I can resolve the problem.

What I am really saying is that I have appreciated all the help you have all given, but feel that I should not be taking up more of your time. Maybe I should just stick to creating Windows based Applications (boring, I know) but at least I can resolve most problems without relying on the good nature of others.

I know (obviously) that the answer is out there otherwise there would not be so many successfully creating and writing programs that work on mobile phones.

So, I say a big THANK YOU to you all.
Best Regards, Steve
Dragondos2020

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Creating Apps for use on Android mobile phones

Post by bogs » Mon May 04, 2020 3:43 pm

Dragondos2020 wrote:
Mon May 04, 2020 3:22 pm
What I am really saying is that I have appreciated all the help you have all given, but feel that I should not be taking up more of your time. Maybe I should just stick to creating Windows based Applications (boring, I know) but at least I can resolve most problems without relying on the good nature of others.
Steve, please do not feel that way at all. The people who contribute here do so because they want to, no one holds a gun to their heads. Everyone knows something different than others, and pool knowledge should be shared.

I guess what I am trying to say is, yes, you should attempt things on your own, yes, you should definitely read (and re-read) answers given, and yes, experiment like crazy, but do not ever feel like you are using up too much of the resources available here. After all, if you are stuck somewhere, then I guarantee you others are as well.
Image

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Creating Apps for use on Android mobile phones

Post by sphere » Mon May 04, 2020 4:08 pm

bogs wrote:
Mon May 04, 2020 3:43 pm
I guess what I am trying to say is, yes, you should attempt things on your own, yes, you should definitely read (and re-read) answers given, and yes, experiment like crazy, but do not ever feel like you are using up too much of the resources available here. After all, if you are stuck somewhere, then I guarantee you others are as well.
Yep, you are almost there.
My solution is not the holy grail. I just know it works by trial and error. I misinterpret solutions from others all the time, because English is not my native tong. So indeed re-read. And keep trying.
Make use of short pieces, create a pause in the script by using ANSWER or MOBILETOAST for little steps, then you know exact where what is going on.

I suspect something with your copying the db file from resources to documents is going false. Because you are probably using a db file which already has the tables. and it still keeps saying that the table don't exist.
Little steps, first be sure you have the db file where it has to be. and LC can tell you that, no need for other tools.
Keep punching Stallone still says!

Dragondos2020
Posts: 29
Joined: Mon Apr 20, 2020 1:00 pm

Re: Creating Apps for use on Android mobile phones

Post by Dragondos2020 » Mon May 04, 2020 5:23 pm

Thank you both for your response and encouraging comments. As you can tell, I am still struggling in trying to get to what appears to be a relatively solution.

I will thanks, keep trying. And based on your encouragement I will not be shy in accepting additional help. I was just concerned that I was taking advantage of the generosity of more experienced LiveCoders.

Thanks

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Creating Apps for use on Android mobile phones

Post by sphere » Mon May 04, 2020 8:59 pm

Your questions are legit. Anyone who learns takes advantage. It's not misuse. You're honest, your questions are normal, so keep asking.

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: Creating Apps for use on Android mobile phones

Post by AxWald » Tue May 05, 2020 1:13 pm

Hi,
Dragondos2020 wrote:
Mon May 04, 2020 10:59 am
There must definitely be a problem within my script. I have made so many different amendments that I am slightly loosing the thought process.
Hehe, this is all but unknown to me. It's usually when I start to delete perfectly good code to solve a problem that hides somewhere else ... A good way to fight it is, IMHO, to drop all that I made until now, reduce the problem to the bare minimum, in a new stack and work from there. Until all bugs are defeated, and the code is nice & fast.
Only then I re-implement this into the previous version.

So I did this for here. I made a tiny SQLite db, and a most simple stack to handle it. And then I fought it until it surrendered, even on my Android tablet. See the attached stack. Works flawlessly, for me. I have commented it extensively, for education.

And don't hesitate to ask further questions - whoever answers here does it voluntarily, and quite often is able to improve their own knowledge on the way. For instance, I came to the suspicion that there's something strange with things like:

Code: Select all

      if not (there is a file (specialFolderPath("documents") & slash & myDBName)) then
This worked well in the IDE, but gave me problems on Android. Once I changed to:

Code: Select all

      set the defaultfolder to specialfolderPath("documents") & slash
      if not (myDBName is in the files) then
it worked, finally. In the progress I plundered the code of one of my older apps & found that what I use here in the demo is much sleeker & more elegant - update time! ;-)

I really recommend to check my approach with the encapsulated database functions ("DoSQL()" etc.) - it will save you this much work! And you may check the "Debug" button & its capabilities - development for mobile is so much easier with it!

OK, try this if you like, and let's see if we don't get your problem solved. Good luck!
Attachments
SQLiteAndroidDemo.zip
SQLite & Android - set it up and handle queries
(9 KiB) Downloaded 205 times
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

Post Reply

Return to “Android Deployment”