The Cursor interface is used to iterate over the results returned from a database query.
Allows access to SQLite specifically connecting to a database and executing sql queries on the data.
platform specific nuances prevented this approach from working out, we improved the native iOS support for thread safety instead
Most new devices contain one version of sqlite or another; sqlite is a very lightweight SQL database designed for embedding into devices. For portability we recommend avoiding SQL altogether since it is both fragmented between devices (different sqlite versions) and isn't supported on all devices.
In general SQL seems overly complex for most embedded device programming tasks.
You will notice that at this time support is still missing from the Windows builds.
The biggest issue with SQLite portability is in iOS. The SQLite version for most platforms is threadsafe and as a result very stable. However, the iOS version is not!
This might not seem like a big deal normally, however if you forget to close a connection the GC might close it for you thus producing a crash. This is such a common occurrence that Codename One logs a warning when the GC collects a database resource on the simulator.
SQL is pretty powerful and very well suited for common tabular data. The Codename One SQL API is similar in spirit to JDBC but considerably simpler since many of the abstractions of JDBC designed for pluggable database architecture make no sense for a local database.
Database API is a high level abstraction that allows you to open an
arbitrary database file using syntax such as:
Some SQLite apps ship with a "ready made" database. We allow you to replace the DB file by using the code:
You can then use the
FileSystemStorage class to write the content of your
DB file into the path. Notice that it must be a valid SQLite file!
This is very useful for applications that need to synchronize with a central server or applications that ship with a large database as part of their core product.
Working with a database is pretty trivial, the application logic below can send arbitrary queries to the
database and present the results in a
Table. You can probably integrate
this code into your app as a debugging tool: