I was just wondering if anyone has tried to exploit the webviewer component to give access to a localised sqlite database within an app without using any extensions?
I was thinking that it may be done using:
sql.js loaded as a webpage into a webviewer
using the webviewstring functionality to send in SQL queries and for getting the result of those queries
Note quite sure how you would load an SQLite file into the browser component however.
Anyway, has anyone tried this? Anyone think it is feasible?
Not seen anyone trying it. Why not give it a go, see how you get on, and report back.
You may need an extension that extends the webviewer's features to get it to work ?
Suggest just try generating a virtual db first. You could then convert a local db to base64 string to transfer it to the webviewer using webviewstring, then convert back to a database object.
You might also consider using localStorage as a simple database for key:pair values....
Must use SQL so that relational databases can be developed, normalised and queried.
Can run on iOS and Android, which means no extensions.
I know I could just set up a remote database and work that way, but I am after a local on device solution (less moving pieces for students to deal with initially).
Given I have no experience of sql.js, my approach would be:
Get it running on my computer using only local files (no server) - learn how it works
Test the same in a webviewer, with companion / compiled app
Work up a solution to load/use/save a db file from the device
It should be platform independent - but there may be quirks to deal with for both Android and iOS
Need to remember it is SQLite and not SQL - maybe just semantics ....
Yes, iOS does have SQLite by default, however, App Inventor for iOS can't run extensions so I need a 'vanilla' App Inventor solution so it can run on both iOS and Android devices.
You can import and export a database file as a Uint8Array
(in AppInventor we would most likely convert this to/from a base64 string so that we can use the webviewstring)
Been having a think about this, based upon what I have learnt so far:
You could possibly load a local sqlite.db file from the assets, but this would only be a read only location
It should be possible to make the sql.js database persistent, based upon what I have seen from the sql.js examples
Extensions would be required to a) convert db files to base64 and back again to files (in order to use the webviewstring), b) simplify the functionality for loading/saving db files using the input=file tag and the Android Download Manager.
I don't know where it saves the data, in MIT Companion the file is created
\Android\data\edu.mit.appinventor.aicompanion3\files\AppInventor\databases\hashTable.db