Java Code Examples for androidx.sqlite.db.SupportSQLiteDatabase#execSQL()
The following examples show how to use
androidx.sqlite.db.SupportSQLiteDatabase#execSQL() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BindShortDataSource.java From kripton with Apache License 2.0 | 6 votes |
/** * onCreate */ @Override protected void onCreate(SupportSQLiteDatabase database) { // generate tables // log section create BEGIN if (this.logEnabled) { if (options.inMemory) { Logger.info("Create database in memory"); } else { Logger.info("Create database '%s' version %s",this.name, this.version); } } // log section create END // log section create BEGIN if (this.logEnabled) { Logger.info("DDL: %s",ShortBeanTable.CREATE_TABLE_SQL); } // log section create END database.execSQL(ShortBeanTable.CREATE_TABLE_SQL); if (options.databaseLifecycleHandler != null) { options.databaseLifecycleHandler.onCreate(database); } justCreated=true; }
Example 2
Source File: BindPerson1DataSource.java From kripton with Apache License 2.0 | 6 votes |
/** * onCreate */ @Override protected void onCreate(SupportSQLiteDatabase database) { // generate tables // log section create BEGIN if (this.logEnabled) { if (options.inMemory) { Logger.info("Create database in memory"); } else { Logger.info("Create database '%s' version %s",this.name, this.version); } } // log section create END // log section create BEGIN if (this.logEnabled) { Logger.info("DDL: %s",PersonTable.CREATE_TABLE_SQL); } // log section create END database.execSQL(PersonTable.CREATE_TABLE_SQL); if (options.databaseLifecycleHandler != null) { options.databaseLifecycleHandler.onCreate(database); } justCreated=true; }
Example 3
Source File: BindAlbumDataSource.java From kripton with Apache License 2.0 | 6 votes |
/** * onCreate */ @Override protected void onCreate(SupportSQLiteDatabase database) { // generate tables // log section create BEGIN if (this.logEnabled) { if (options.inMemory) { Logger.info("Create database in memory"); } else { Logger.info("Create database '%s' version %s",this.name, this.version); } } // log section create END // log section create BEGIN if (this.logEnabled) { Logger.info("DDL: %s",AlbumTable.CREATE_TABLE_SQL); } // log section create END database.execSQL(AlbumTable.CREATE_TABLE_SQL); if (options.databaseLifecycleHandler != null) { options.databaseLifecycleHandler.onCreate(database); } justCreated=true; }
Example 4
Source File: BindAppDataSource.java From kripton with Apache License 2.0 | 6 votes |
/** * onCreate */ @Override protected void onCreate(SupportSQLiteDatabase database) { // generate tables // log section create BEGIN if (this.logEnabled) { if (options.inMemory) { Logger.info("Create database in memory"); } else { Logger.info("Create database '%s' version %s",this.name, this.version); } } // log section create END // log section create BEGIN if (this.logEnabled) { Logger.info("DDL: %s",CityTable.CREATE_TABLE_SQL); } // log section create END database.execSQL(CityTable.CREATE_TABLE_SQL); if (options.databaseLifecycleHandler != null) { options.databaseLifecycleHandler.onCreate(database); } justCreated=true; }
Example 5
Source File: BindUserDataSource.java From kripton with Apache License 2.0 | 6 votes |
/** * onCreate */ @Override protected void onCreate(SupportSQLiteDatabase database) { // generate tables // log section create BEGIN if (this.logEnabled) { if (options.inMemory) { Logger.info("Create database in memory"); } else { Logger.info("Create database '%s' version %s",this.name, this.version); } } // log section create END // log section create BEGIN if (this.logEnabled) { Logger.info("DDL: %s",UserTable.CREATE_TABLE_SQL); } // log section create END database.execSQL(UserTable.CREATE_TABLE_SQL); if (options.databaseLifecycleHandler != null) { options.databaseLifecycleHandler.onCreate(database); } justCreated=true; }
Example 6
Source File: BindPersonDataSource.java From kripton with Apache License 2.0 | 6 votes |
/** * onCreate */ @Override protected void onCreate(SupportSQLiteDatabase database) { // generate tables // log section create BEGIN if (this.logEnabled) { if (options.inMemory) { Logger.info("Create database in memory"); } else { Logger.info("Create database '%s' version %s",this.name, this.version); } } // log section create END // log section create BEGIN if (this.logEnabled) { Logger.info("DDL: %s",PersonTable.CREATE_TABLE_SQL); } // log section create END database.execSQL(PersonTable.CREATE_TABLE_SQL); if (options.databaseLifecycleHandler != null) { options.databaseLifecycleHandler.onCreate(database); } justCreated=true; }
Example 7
Source File: BindSchoolLunchDataSource.java From kripton with Apache License 2.0 | 6 votes |
/** * onCreate */ @Override protected void onCreate(SupportSQLiteDatabase database) { // generate tables // log section create BEGIN if (this.logEnabled) { if (options.inMemory) { Logger.info("Create database in memory"); } else { Logger.info("Create database '%s' version %s",this.name, this.version); } } // log section create END // log section create BEGIN if (this.logEnabled) { Logger.info("DDL: %s",SchoolLunchTable.CREATE_TABLE_SQL); } // log section create END database.execSQL(SchoolLunchTable.CREATE_TABLE_SQL); if (options.databaseLifecycleHandler != null) { options.databaseLifecycleHandler.onCreate(database); } justCreated=true; }
Example 8
Source File: RekeyTest.java From cwac-saferoom with Apache License 2.0 | 6 votes |
@Test public void rekeyCharArray() throws IOException { SafeHelperFactory factory= SafeHelperFactory.fromUser(new SpannableStringBuilder("sekrit")); SupportSQLiteOpenHelper helper= factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME, new Callback(1)); SupportSQLiteDatabase db=helper.getWritableDatabase(); assertOriginalContent(db); SafeHelperFactory.rekey(db, PASSPHRASE.toCharArray()); assertOriginalContent(db); db.execSQL("UPDATE foo SET bar=?, goo=?", new Object[] {3, "four"}); assertUpdatedContent(db); db.close(); factory=SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE)); helper=factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME, new Callback(1)); db=helper.getWritableDatabase(); assertUpdatedContent(db); }
Example 9
Source File: BindBeanDataSource.java From kripton with Apache License 2.0 | 6 votes |
/** * onCreate */ @Override protected void onCreate(SupportSQLiteDatabase database) { // generate tables // log section create BEGIN if (this.logEnabled) { if (options.inMemory) { Logger.info("Create database in memory"); } else { Logger.info("Create database '%s' version %s",this.name, this.version); } } // log section create END // log section create BEGIN if (this.logEnabled) { Logger.info("DDL: %s",BeanTable.CREATE_TABLE_SQL); } // log section create END database.execSQL(BeanTable.CREATE_TABLE_SQL); if (options.databaseLifecycleHandler != null) { options.databaseLifecycleHandler.onCreate(database); } justCreated=true; }
Example 10
Source File: BindPersonCirtyErr3DataSource.java From kripton with Apache License 2.0 | 5 votes |
/** * onCreate */ @Override protected void onCreate(SupportSQLiteDatabase database) { // generate tables // log section create BEGIN if (this.logEnabled) { if (options.inMemory) { Logger.info("Create database in memory"); } else { Logger.info("Create database '%s' version %s",this.name, this.version); } } // log section create END // log section create BEGIN if (this.logEnabled) { Logger.info("DDL: %s",PersonTable.CREATE_TABLE_SQL); } // log section create END database.execSQL(PersonTable.CREATE_TABLE_SQL); // log section create BEGIN if (this.logEnabled) { Logger.info("DDL: %s",CityTable.CREATE_TABLE_SQL); } // log section create END database.execSQL(CityTable.CREATE_TABLE_SQL); // log section create BEGIN if (this.logEnabled) { Logger.info("DDL: %s",PersonCityErr3Table.CREATE_TABLE_SQL); } // log section create END database.execSQL(PersonCityErr3Table.CREATE_TABLE_SQL); if (options.databaseLifecycleHandler != null) { options.databaseLifecycleHandler.onCreate(database); } justCreated=true; }
Example 11
Source File: GroupDatabase.java From bcm-android with GNU General Public License v3.0 | 5 votes |
@Override public void migrate(@NonNull SupportSQLiteDatabase database) { ALog.i("Database", "+++++++++++++++++++++++database upgrade(18, 19) "); try { database.execSQL("ALTER TABLE " + NoteRecord.TABLE_NAME + " ADD COLUMN `digest` TEXT"); } catch (Exception e) { ALog.e("Database", "+++++++++++++++++++++++database upgrade(18, 19) error " + e); } }
Example 12
Source File: BindBean96DataSource.java From kripton with Apache License 2.0 | 4 votes |
/** * onUpgrade */ @Override protected void onUpgrade(SupportSQLiteDatabase database, int previousVersion, int currentVersion) { // log section BEGIN if (this.logEnabled) { Logger.info("Update database '%s' from version %s to version %s",this.name, previousVersion, currentVersion); } // log section END // if we have a list of update task, try to execute them if (options.updateTasks != null) { List<SQLiteUpdateTask> tasks = buildTaskList(previousVersion, currentVersion); for (SQLiteUpdateTask task : tasks) { // log section BEGIN if (this.logEnabled) { Logger.info("Begin update database from version %s to %s", previousVersion, previousVersion+1); } // log section END task.execute(database, previousVersion, previousVersion+1); // log section BEGIN if (this.logEnabled) { Logger.info("End update database from version %s to %s", previousVersion, previousVersion+1); } // log section END previousVersion++; } } else { // drop all tables SQLiteUpdateTaskHelper.dropTablesAndIndices(database); // generate tables // log section BEGIN if (this.logEnabled) { Logger.info("DDL: %s",Bean205Table.CREATE_TABLE_SQL); } // log section END database.execSQL(Bean205Table.CREATE_TABLE_SQL); } if (options.databaseLifecycleHandler != null) { options.databaseLifecycleHandler.onUpdate(database, previousVersion, currentVersion, true); } }
Example 13
Source File: BindPersonDataSource.java From kripton with Apache License 2.0 | 4 votes |
/** * onUpgrade */ @Override protected void onUpgrade(SupportSQLiteDatabase database, int previousVersion, int currentVersion) { // log section BEGIN if (this.logEnabled) { Logger.info("Update database '%s' from version %s to version %s",this.name, previousVersion, currentVersion); } // log section END // if we have a list of update task, try to execute them if (options.updateTasks != null) { List<SQLiteUpdateTask> tasks = buildTaskList(previousVersion, currentVersion); for (SQLiteUpdateTask task : tasks) { // log section BEGIN if (this.logEnabled) { Logger.info("Begin update database from version %s to %s", previousVersion, previousVersion+1); } // log section END task.execute(database, previousVersion, previousVersion+1); // log section BEGIN if (this.logEnabled) { Logger.info("End update database from version %s to %s", previousVersion, previousVersion+1); } // log section END previousVersion++; } } else { // drop all tables SQLiteUpdateTaskHelper.dropTablesAndIndices(database); // generate tables // log section BEGIN if (this.logEnabled) { Logger.info("DDL: %s",PersonTable.CREATE_TABLE_SQL); } // log section END database.execSQL(PersonTable.CREATE_TABLE_SQL); } if (options.databaseLifecycleHandler != null) { options.databaseLifecycleHandler.onUpdate(database, previousVersion, currentVersion, true); } }
Example 14
Source File: BindXenoDataSource.java From kripton with Apache License 2.0 | 4 votes |
/** * onUpgrade */ @Override protected void onUpgrade(SupportSQLiteDatabase database, int previousVersion, int currentVersion) { // log section BEGIN if (this.logEnabled) { Logger.info("Update database '%s' from version %s to version %s",this.name, previousVersion, currentVersion); } // log section END // if we have a list of update task, try to execute them if (options.updateTasks != null) { List<SQLiteUpdateTask> tasks = buildTaskList(previousVersion, currentVersion); for (SQLiteUpdateTask task : tasks) { // log section BEGIN if (this.logEnabled) { Logger.info("Begin update database from version %s to %s", previousVersion, previousVersion+1); } // log section END task.execute(database, previousVersion, previousVersion+1); // log section BEGIN if (this.logEnabled) { Logger.info("End update database from version %s to %s", previousVersion, previousVersion+1); } // log section END previousVersion++; } } else { // drop all tables SQLiteUpdateTaskHelper.dropTablesAndIndices(database); // generate tables // log section BEGIN if (this.logEnabled) { Logger.info("DDL: %s",PrefixConfigTable.CREATE_TABLE_SQL); } // log section END database.execSQL(PrefixConfigTable.CREATE_TABLE_SQL); // log section BEGIN if (this.logEnabled) { Logger.info("DDL: %s",PhoneNumberTable.CREATE_TABLE_SQL); } // log section END database.execSQL(PhoneNumberTable.CREATE_TABLE_SQL); // log section BEGIN if (this.logEnabled) { Logger.info("DDL: %s",PersonTable.CREATE_TABLE_SQL); } // log section END database.execSQL(PersonTable.CREATE_TABLE_SQL); // log section BEGIN if (this.logEnabled) { Logger.info("DDL: %s",CountryTable.CREATE_TABLE_SQL); } // log section END database.execSQL(CountryTable.CREATE_TABLE_SQL); // log section BEGIN if (this.logEnabled) { Logger.info("DDL: %s",PersonPhoneNumberTable.CREATE_TABLE_SQL); } // log section END database.execSQL(PersonPhoneNumberTable.CREATE_TABLE_SQL); } if (options.databaseLifecycleHandler != null) { options.databaseLifecycleHandler.onUpdate(database, previousVersion, currentVersion, true); } }
Example 15
Source File: BindSchoolDataSource.java From kripton with Apache License 2.0 | 4 votes |
/** * onUpgrade */ @Override protected void onUpgrade(SupportSQLiteDatabase database, int previousVersion, int currentVersion) { // log section BEGIN if (this.logEnabled) { Logger.info("Update database '%s' from version %s to version %s",this.name, previousVersion, currentVersion); } // log section END // if we have a list of update task, try to execute them if (options.updateTasks != null) { List<SQLiteUpdateTask> tasks = buildTaskList(previousVersion, currentVersion); for (SQLiteUpdateTask task : tasks) { // log section BEGIN if (this.logEnabled) { Logger.info("Begin update database from version %s to %s", previousVersion, previousVersion+1); } // log section END task.execute(database, previousVersion, previousVersion+1); // log section BEGIN if (this.logEnabled) { Logger.info("End update database from version %s to %s", previousVersion, previousVersion+1); } // log section END previousVersion++; } } else { // drop all tables SQLiteUpdateTaskHelper.dropTablesAndIndices(database); // generate tables // log section BEGIN if (this.logEnabled) { Logger.info("DDL: %s",SeminarTable.CREATE_TABLE_SQL); } // log section END database.execSQL(SeminarTable.CREATE_TABLE_SQL); // log section BEGIN if (this.logEnabled) { Logger.info("DDL: %s",StudentTable.CREATE_TABLE_SQL); } // log section END database.execSQL(StudentTable.CREATE_TABLE_SQL); // log section BEGIN if (this.logEnabled) { Logger.info("DDL: %s",Seminar2StudentTable.CREATE_TABLE_SQL); } // log section END database.execSQL(Seminar2StudentTable.CREATE_TABLE_SQL); // log section BEGIN if (this.logEnabled) { Logger.info("DDL: %s",ProfessorTable.CREATE_TABLE_SQL); } // log section END database.execSQL(ProfessorTable.CREATE_TABLE_SQL); } if (options.databaseLifecycleHandler != null) { options.databaseLifecycleHandler.onUpdate(database, previousVersion, currentVersion, true); } }
Example 16
Source File: BindAppDataSource.java From kripton with Apache License 2.0 | 4 votes |
/** * onUpgrade */ @Override protected void onUpgrade(SupportSQLiteDatabase database, int previousVersion, int currentVersion) { // log section BEGIN if (this.logEnabled) { Logger.info("Update database '%s' from version %s to version %s",this.name, previousVersion, currentVersion); } // log section END // if we have a list of update task, try to execute them if (options.updateTasks != null) { List<SQLiteUpdateTask> tasks = buildTaskList(previousVersion, currentVersion); for (SQLiteUpdateTask task : tasks) { // log section BEGIN if (this.logEnabled) { Logger.info("Begin update database from version %s to %s", previousVersion, previousVersion+1); } // log section END task.execute(database, previousVersion, previousVersion+1); // log section BEGIN if (this.logEnabled) { Logger.info("End update database from version %s to %s", previousVersion, previousVersion+1); } // log section END previousVersion++; } } else { // drop all tables SQLiteUpdateTaskHelper.dropTablesAndIndices(database); // generate tables // log section BEGIN if (this.logEnabled) { Logger.info("DDL: %s",BookTable.CREATE_TABLE_SQL); } // log section END database.execSQL(BookTable.CREATE_TABLE_SQL); // log section BEGIN if (this.logEnabled) { Logger.info("DDL: %s",UserTable.CREATE_TABLE_SQL); } // log section END database.execSQL(UserTable.CREATE_TABLE_SQL); // log section BEGIN if (this.logEnabled) { Logger.info("DDL: %s",LoanTable.CREATE_TABLE_SQL); } // log section END database.execSQL(LoanTable.CREATE_TABLE_SQL); } if (options.databaseLifecycleHandler != null) { options.databaseLifecycleHandler.onUpdate(database, previousVersion, currentVersion, true); } }
Example 17
Source File: MigratingImportTest.java From cwac-saferoom with Apache License 2.0 | 4 votes |
@Override public void migrate(@NonNull SupportSQLiteDatabase db) { db.execSQL("CREATE TABLE IF NOT EXISTS `SillyEntity` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)"); }
Example 18
Source File: BindDummy01DataSource.java From kripton with Apache License 2.0 | 4 votes |
/** * onUpgrade */ @Override protected void onUpgrade(SupportSQLiteDatabase database, int previousVersion, int currentVersion) { // log section BEGIN if (this.logEnabled) { Logger.info("Update database '%s' from version %s to version %s",this.name, previousVersion, currentVersion); } // log section END // if we have a list of update task, try to execute them if (options.updateTasks != null) { List<SQLiteUpdateTask> tasks = buildTaskList(previousVersion, currentVersion); for (SQLiteUpdateTask task : tasks) { // log section BEGIN if (this.logEnabled) { Logger.info("Begin update database from version %s to %s", previousVersion, previousVersion+1); } // log section END task.execute(database, previousVersion, previousVersion+1); // log section BEGIN if (this.logEnabled) { Logger.info("End update database from version %s to %s", previousVersion, previousVersion+1); } // log section END previousVersion++; } } else { // drop all tables SQLiteUpdateTaskHelper.dropTablesAndIndices(database); // generate tables // log section BEGIN if (this.logEnabled) { Logger.info("DDL: %s",Bean01Table.CREATE_TABLE_SQL); } // log section END database.execSQL(Bean01Table.CREATE_TABLE_SQL); } if (options.databaseLifecycleHandler != null) { options.databaseLifecycleHandler.onUpdate(database, previousVersion, currentVersion, true); } }
Example 19
Source File: BindQuickStartDataSource.java From kripton with Apache License 2.0 | 4 votes |
/** * onCreate */ @Override protected void onCreate(SupportSQLiteDatabase database) { // generate tables // log section create BEGIN if (this.logEnabled) { if (options.inMemory) { Logger.info("Create database in memory"); } else { Logger.info("Create database '%s' version %s",this.name, this.version); } } // log section create END // log section create BEGIN if (this.logEnabled) { Logger.info("DDL: %s",UserTable.CREATE_TABLE_SQL); } // log section create END database.execSQL(UserTable.CREATE_TABLE_SQL); // log section create BEGIN if (this.logEnabled) { Logger.info("DDL: %s",PostTable.CREATE_TABLE_SQL); } // log section create END database.execSQL(PostTable.CREATE_TABLE_SQL); // log section create BEGIN if (this.logEnabled) { Logger.info("DDL: %s",CommentTable.CREATE_TABLE_SQL); } // log section create END database.execSQL(CommentTable.CREATE_TABLE_SQL); // log section create BEGIN if (this.logEnabled) { Logger.info("DDL: %s",TodoTable.CREATE_TABLE_SQL); } // log section create END database.execSQL(TodoTable.CREATE_TABLE_SQL); if (options.databaseLifecycleHandler != null) { options.databaseLifecycleHandler.onCreate(database); } justCreated=true; }
Example 20
Source File: BindPKDataSource.java From kripton with Apache License 2.0 | 4 votes |
/** * onUpgrade */ @Override protected void onUpgrade(SupportSQLiteDatabase database, int previousVersion, int currentVersion) { // log section BEGIN if (this.logEnabled) { Logger.info("Update database '%s' from version %s to version %s",this.name, previousVersion, currentVersion); } // log section END // if we have a list of update task, try to execute them if (options.updateTasks != null) { List<SQLiteUpdateTask> tasks = buildTaskList(previousVersion, currentVersion); for (SQLiteUpdateTask task : tasks) { // log section BEGIN if (this.logEnabled) { Logger.info("Begin update database from version %s to %s", previousVersion, previousVersion+1); } // log section END task.execute(database, previousVersion, previousVersion+1); // log section BEGIN if (this.logEnabled) { Logger.info("End update database from version %s to %s", previousVersion, previousVersion+1); } // log section END previousVersion++; } } else { // drop all tables SQLiteUpdateTaskHelper.dropTablesAndIndices(database); // generate tables // log section BEGIN if (this.logEnabled) { Logger.info("DDL: %s",PKBeanTable.CREATE_TABLE_SQL); } // log section END database.execSQL(PKBeanTable.CREATE_TABLE_SQL); } if (options.databaseLifecycleHandler != null) { options.databaseLifecycleHandler.onUpdate(database, previousVersion, currentVersion, true); } }