Here is an entry to add to the /res/values/strings.xml file for the database version number. INSERT INTO "picnic_table" VALUES ('paper') DROP TABLE "picnic_table" Uncomment this if picnic table was previously created and now is being replaced.ĬREATE TABLE "picnic_table" ("plates" TEXT) * CREATE TABLE "dining_room_table" This is a second type of comment in sql. It is ignored by parseSql.ĬREATE TABLE "pool_table" This is a third type of comment in sql. * CREATE TABLE "coffee_table" This is a second type of comment in sql. (NOTE: Notice that all three types of SQL comments will be ignored by the sql parser that is included in this example.) -CREATE TABLE "kitchen_table" This is one type of comment in sql. It is to be placed in the assets folder of the project for the internal method or copied into the "Execute SQL' of SQLite Manager to create the database for the external method. Here is a sample update_database.sql file. INSERT INTO "android_metadata" VALUES ('en_US') (NOTE: Notice the comment about the table required by Android.) -Android requires a table named 'android_metadata' with a 'locale' columnĬREATE TABLE "android_metadata" ("locale" TEXT DEFAULT 'en_US') Here is a sample create_database.sql file. The example below demonstrates how to use either method. The data in the database will remain unchanged except when its container is removed, for example dropping a table. Upgrades would then be accomplished by processing an upgrade sql file. Upgrades are triggered by changing the database version number in the res/values/strings.xml file. This is not as quick but the delay would probably be unnoticeable to the users if the database has only a few tables. The other option is to create a database internally from a sql file. You can create a database originally by using the SQLite Manager FireFox plugin to execute your creation sql statements. Upgrades would then be accomplished by creating a new database externally, replacing the old database in the assets folder with the new database, saving the old database in internal storage under another name, copying the new database from the assets folder into internal storage, transferring all of the data from the old database (that was renamed earlier) into the new database and finally deleting the old database. This is much quicker if the database has a lot of tables and other components. One is to create a database externally, then place it in the assets folder of the project and then copy the entire database from there. There are two options for creating and updating databases.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |