I am making a contact book application in Qt.
I want my application to automatically create an QSQLITE database when it first runs and then access this database in future?
Is there a way to do this?
Ya you can create sqlite database at its first run and can make it progressive. Just do it in the constructor of your App and check for the existence of db before cerating it, else don't create. You can access database in subsequent runs of your same App or different App.
Use db.setDatabaseName("databasename.db"); instead of db.setDatabaseName(":memory:");, now your database will be persistent.
Related
I have deployed the 1st version of my wp8 in wp store and now i want to deploy the update version of it. Though I know the process of update deployment, but my concern is the sqlite file which doesn't get updated.
Here is the scenario, I have sqlite file in the app where user can store config and setting, in new version I added extra tables and I want to these tables should be reflected in the the update without affecting user settings and config.
What points I should consider to take care of this issue?
Thanks!
Assuming the data in the sqlite database is static you can give the database a new name and submit it with the updated app. One first run copy the new database to isolated storage and delete the old version of the database to save space.
If the user is inputting data into the database you will have to include code to modify the database structure on the first run and insert any records into the new table
I went thru the docs but couldn't find how can I perform specific operations when app is being installed or when app is being updated.
What I want to do is, create table when app is being installed and if in future, db schema changes, I want to perform those operations when app is being updated.
According to me .. the best place to do these changes are in the code. so whenever the application starts up first time after getting updated.. you do all the db schema changes.
This makes sure that your application is fully updated before you touch any database and secondly u do not have to write any special logic separately while installing / updating the application.
I have an AIR application and I would like use SQLite instead of an XML file to populate the database. I've seen people create the database on the fly and import the data when the application first launches. But also people are using existing databases. What approach do you use to prepopulate the database? Is there a tool to enter basic initial data (~200 records and 2 tables) or should I create the database and contents manually when the app is first installed.
More context
This is a mobile AIR application using Flex 4.6.
There are numerous tools to manage SQLite databases, such as Lita which is an open source AIR application.
If there is no need to revert the database back to its original content, then it could simply be packaged in the app with your populated content.
If restoring the database to its original populated data is required, you could keep a copy of the original database and stage it to the active database in use, thereby replacing the database.
Depending on data and parity of your app to the database model, it wouldn't be unreasonable to populate your database via programmatic implementation in code executed at first launch. There is overhead both in initial launch of your app and perhaps mostly in code you must generate and maintain to create the database.
Typically, I would only follow this pattern if I have a default model with serialization of that model. As in, if I had already built a commit of preferences style data from my models to persist in a database.
I want to create a database on my blackberry device when my app is installed. I did not find any event (e.g. onInstalled) so that i can create my databse on this event when the app is installed.
Apparently there is a method DatabaseFactory.exists() which i can use to check if the database exists or not. But i do not want to check for this every time. I want to create the database when my app is installed and when the app is un-installed then the database should also get deleted.
Thanks
As far as I know RIM API SDK does not provide mechanism to catch install/uninstall events.
And even the database is once created it can be deleted/damaged via the filesystem. For instance user deletes database files from the media-card or from the device memory. Just because user does not know what these files contain and assumes these as temporary or something else.
It is a good approach to check the database presence before starting work with it. Otherwise user may get blank white screen with text "Exception 1234" and some additional text, or may get a popup with strange message, like "Error: FileNotFoundException...".
See the SQLiteDemo in the blackberry samples demo then you can get solution.
I'm working with sqlite and qt. I understand that sqlite doesn't have native user access control and am fine with that, and have a plan for controlling access using my application - set up some user groups in a db and authenticate on the app side.
What I would like to know is if there is an easy way to stop my views on QSqlRelationalTableModel data from updating the database (i.e make the database readonly).
I am currently using an editstrategy of OnFieldChange, if I change it to OnManualSubmit for example (without implementing a submit call), will that prevent updates to the dB?
Is there a cleverer way of doing this? Like making the view readonly?
If you create views, then they will be read-only since sqlite doesn't support updating views:
http://www.sqlite.org/lang_createview.html
EDIT
Following-up on your comment, is the QSQLITE_OPEN_READONLY connection setting what you are looking for?
http://doc.trolltech.com/4.6/qsqldatabase.html#setConnectOptions