Since, if I am not wrong, we depend on an Apache Cordova plugin... are you sure that the above code is executed after the app Ready event? I can't see anything except that maybe the "args" variable must be preceded with the "var" reserved word... :-(
I have this custom plugin referenced in the app settings Cordova area: cordova-sqlite-storage
I did end up wrapping the JS in
That did not seem to make any difference.
The problem is probably the database or the name or the location. I did not try this plugin, but, asume that the database name must refer to some existing database file. If so, probably we can't simply use a database name like "pts.db3", but something like "app/files/pts.db3", suposing we include the "pts.db3" file using the app files manager and from the Others (files) tab.
About the device ready, probably the code no need to be wrapper inside that event handler: for example, if you execute the code in certain Push button Click event, once the app has started (of course), maybe in other app view than the main one, then the device ready event has been already fired, and therefore we can use the code "as is" without problems. But if the code is placed in the main app view Show event... then is possible that that code are executed before the device ready event is fired.
So I added the SQLite database to the files located in the project file manager
Would the location parameter in the openDatabase function be: location: 'app/files/'?
I can't answer at this moment... you must refer to the plugin's documentation: maybe the "name" must be the database's file path, maybe just the database file name, and then use the "location" to place the database's directory... I can't help you right now on this, but you must take a look at the documentation, since there is not the same to set one thing or another...
If you use the app files manager and the Others tab, then choose the "pts.db3" file from your computer, when the app is compiled, that file is copied into the "app/files/" directory, so their path is "app/files/pts.db3". Be sure that you use the files manager and be sure that you can find that file in "app/files/".
I have the database pts.db3 loaded in the file manager. On the emulator I have navigated to Files --> Android SDK built for x86 --> Android -->Data --> com.ptsapp.pts --> files -->
That location is empty
I am not understand the Android SDK -> Android... if you add a file from the Other tab in the app files manager, that file is copied with the other app files (HTML, CSS, JS, etc.) in the "app/files/" path. So, if you add a "MyFile.db" from that place, the final path for that file is "app/files/MyFile.db". Are you tried with that? How you try? Can place here the paths that you are trying to use and in what variable are you set it?
The path C:\Sync\Ryan\GitHub Repos\PTS Mobile\PTS_Compiled\www\app\files on my laptop contains the ptd.db3 file but it does not appear on the Android emulator I am testing with.
This is the path I see on the Android emulator: "com.ptsapp.pts/files/" but that folder is empty.
I dont think SQLite database files can be placed in that directory
For sure we can't use the absolute path of your computer: we can choose that file when using the app files manager. To me "com.ptsapp.pts/files/" is rare, because I am not sure where you view this path, or if that is the path in which the plugin expect the database files.
In the best case, the path can be changed with the provided one, so, we can add the database file using the app files manager and therefore can use a path like "app/files/myDatabase.db". Exactly in the same way that you can use another file, like a JSON file, for example.
In the worst case, the plugin expect the files to be in the path that you referred... so we must manually copy the database file in that path, which must be inside some of the "platforms\android\" folders... the point is that the plugin's documentation must be clear about all of this...
According to the plugin documentation using this code will open the database, but also create a new database if one is not present.
The location called 'default' in the code snippet refers to this location: "//data/data/
This location is not visible to browsing. My code in AB is using the "openDatabase" method, but I don't know if it is working. The code that creates the database, also executes some SQL to create tables if they do not exist.
My project requirement is to build an app on Android tablets that can go offline for an extended period of time and still handle CRUD to a local data source. Once I detect a network connection, I update data to a web SQL Server database via API functions that I wrote.
I am open to any ideas to achieve this requirement. I have put alot of time into this AB project and really want to keep using it.
I have considered using JSON as an offline data store but I am not sure how that would handle new and updated records. In addition, some of my database queries from the API will return at minimum 8500 rows of relational data.
Thanks David, I really appreciate your exceptional support. I will mess with a few settings and post back here.
Please, no problem at all. If I was not as busy as I am (and you will know in what in the near future... and I hope that you enjoy it..) I will try the plugin by myself... maybe I can finally do it... there are various samples about JSON (see JSON, JSON2, JSON3 samples apps)... it's quite easy to work with JSON, and, since the FileWrite and FileRead works with text files... and we can serialize any JSON and unserialize it... can be a possible to store complex data offline, that is, something more complex than simply plain text. But the SQLite plugin must work... for sure that must work... or at least we must know what is happen... and if what happen can be solved or what...
Everybody can read the DecSoft's support forum for learning purposes, however only DecSoft's customers can post new threads. Purchase one or more licenses of some DecSoft's products in order to give this and other benefits.