Page 1 of 2
How to test 1st app (using sqlite and datagrid) on AVD
Posted: Wed Aug 28, 2013 2:46 am
by shattuck49
I am writing my 1st app, which uses a sqlite database and a datagrid, and it works fine when tested in the IDE. However, when I test in the AVD, I just get an empty datagrid. Can anyone point me to a tutorial or example on how to test and use sqlite and a datagrid in Android. I've looked at the tutorials and help but have seen nothing that seems to apply to what I am trying to do.
Re: How to test 1st app (using sqlite and datagrid) on AVD
Posted: Wed Aug 28, 2013 5:35 am
by Simon
Hi shattuck49,
Welcome to the forum
Hopefully, for a start, you are building the sql from inside your app,then all you need to do is make sure you have the sqlite box selected from the Standalone Application settings.
If not, then you have include the database in the Copy Files of the Standalone Application settings. It's location will be in specialFolderPath ("engine"). This also means that to update it you will want to move it to specialFolderPath ("documents").
Simon
Re: How to test 1st app (using sqlite and datagrid) on AVD
Posted: Fri Aug 30, 2013 1:11 am
by shattuck49
I have tried both "documents" and "engine" with no luck. I get feedback telling me that sqlite dabase is open (or is it creating a new one?) but when I try to load the data into the datagrid I get nothing. Can LiveCode handle an external sqlite database or does it have to be internal. The tutorials and samples I have seen all created the database.
Re: How to test 1st app (using sqlite and datagrid) on AVD
Posted: Fri Aug 30, 2013 2:56 am
by Simon
Hi shattuck49,
I had meant to build the DB from internal stack sources just because it was your 1st app. But yes you can use the Copy Files tab.
2 things to watch out for
Make sure the DB is closed before you build the standalone.
And move the DB from the engine to documents at the start e.g.
Code: Select all
onOpenCard
put specialFolderPath("documents") & slash & "myData.sqlite" into tPath
if there is not a file tPath then
put url("binfile:" & specialFolderPath("engine") & slash & "myData.sqlite") into tFileContents
put tFileContents into url("binfile:" & specialFolderPath("documents") & slash & "myData.sqlite")
end if
end openCard
If adding data from the desktop to your DB you'll want to get rid of that if/then while testing.
Maybe that will help?
Simon
Re: How to test 1st app (using sqlite and datagrid) on AVD
Posted: Fri Aug 30, 2013 3:54 am
by shattuck49
That did not make any difference (the datagrid was still empty). I pasted your code, changed the database name to mine, and made sure the database was not open. For some reason LiveCode cannot find, open, and read my database in Android although it works fine when tested in the IDE in Windows 7.
Re: How to test 1st app (using sqlite and datagrid) on AVD
Posted: Fri Aug 30, 2013 4:14 am
by Simon
Have you tried the example in this lesson?
http://lessons.runrev.com/s/lessons/m/4 ... e-database
With that and the openCard code, it is working on my device.
When testing with your DB don't hit table or contents buttons just connect and display or it will write a new DB.
Just checking to make sure the DB is there and working. DG later.
Simon
Re: How to test 1st app (using sqlite and datagrid) on AVD
Posted: Sat Aug 31, 2013 6:24 pm
by shattuck49
Still no success. I have tried your code and the tutorial you suggested and my datagrid will only fill when run within the IDE, not the AVD. I notice that the tutorial creates the SQLite database (there is no SQLite file in the "Copy Files" section) where mine copies my SQLite database. I cannot find a tutorial or example where the SQLite database already exists and isn't created in the code. Is it possible to use an existing SQlite database in the AVD and not have to create one within the code for testing purposes. Any help would be appreciated. Thank you.
Re: How to test 1st app (using sqlite and datagrid) on AVD
Posted: Sat Aug 31, 2013 7:25 pm
by Simon
Hi shattuck49,
You didn't mention if you were able to get the tutorial DB running in the emulator? For the "Copy File", if you ran through the example you would have "runrevemails.sqlite" in your documents folder, that's the one you put in copy files.
So, yes you can use an existing DB.
Simon
Re: How to test 1st app (using sqlite and datagrid) on AVD
Posted: Sat Aug 31, 2013 8:24 pm
by shattuck49
Simon,
Yes, I ran the tutorial in the AVD with no problem. And I do have my SQLite database in the "documents" folder like the tutorial. But I still get no data in my datagrid when I test (even though it tests fine in the IDE). I noticed that the code in the tutorial is at the Card level while my code is attached to my "Load Data" button. Does that make a difference? I am using a "Load Data" button, and "Answer" statements, for testing purposes only to see what is happening. Also, any idea why some of my controls are solid black when displayed in the AVD?
Thanks.
John
Re: How to test 1st app (using sqlite and datagrid) on AVD
Posted: Sat Aug 31, 2013 8:54 pm
by Simon
Hi John,
Try the attached stack.
It's a modified version of the tutorial example that I have running here in the emulator.
You will have to put in your Copy File destination, please stick to using the tutorials runrevemails.sqlite.
For now just tell me how this one is working for you. It is near to impossible for me to debug your stack without having it here in front of me.
Having the script in a button or card only matters if another button is trying to run a handler in your load button.
Simon
Re: How to test 1st app (using sqlite and datagrid) on AVD
Posted: Sat Aug 31, 2013 10:48 pm
by shattuck49
Simon,
Your example works fine in the Android emulator. I will go through the code and compare it to mine.
I will let you know what I find.
Thanks.
John
Re: How to test 1st app (using sqlite and datagrid) on AVD
Posted: Tue Sep 03, 2013 1:37 am
by shattuck49
Simon,
Finally tried your code with my SQLite database. Still does not work. Error message is that it cannot find the table in my Select statement (which works fine in the IDE).
I am using the most recent version of SQLite. How can I find out which version is supported by LiveCode (which created the database used in your example) and which version is supported by the Android emulator?
John
Re: How to test 1st app (using sqlite and datagrid) on AVD
Posted: Tue Sep 03, 2013 1:55 am
by Simon
Hi John,
Could you post a reduced set of your .sqlite?
Or just make up a new one that displays the problem?
Simon
Edit: Using a DB made with SQLite Administrator .s3db I was again able to see the data.
One thing I did find was Copy Files does not like using relative paths beneath the stack path (well it does but doesn't copy the file correctly). If the DB is next to the stack it worked or providing a full path to the file works.
Re: How to test 1st app (using sqlite and datagrid) on AVD
Posted: Tue Sep 03, 2013 2:33 am
by shattuck49
Simon,
How do I send you a copy of my database. "Upload attachment" rejected every name I tried for the database.
Re: How to test 1st app (using sqlite and datagrid) on AVD
Posted: Tue Sep 03, 2013 2:47 am
by Simon
Can you zip it?