List of usage examples for android.database.sqlite SQLiteDatabase execSQL
public void execSQL(String sql) throws SQLException
From source file:com.eTilbudsavis.etasdk.DbHelper.java
@Override public void onCreate(SQLiteDatabase database) { synchronized (LOCK) { database.execSQL(CREATE_LIST_TABLE); database.execSQL(CREATE_ITEM_TABLE); database.execSQL(CREATE_SHARE_TABLE); }// w w w . j a va2s .co m }
From source file:project.cs.netinfservice.database.IODatabase.java
/** * Called when the database has been opened. The implementation should check isReadOnly() * before updating the database. This method is called after the database connection has * been configured and after the database schema has been created, upgraded or downgraded * as necessary. If the database connection must be configured in some way before the schema * is created, upgraded, or downgraded, do it in onConfigure(SQLiteDatabase) instead. */// ww w. j a v a 2 s . co m @Override public void onOpen(SQLiteDatabase db) { super.onOpen(db); // Checks if the database is read-only or not if (!db.isReadOnly()) { // Enable foreign key constraints db.execSQL("PRAGMA foreign_keys=ON;"); } }
From source file:net.sf.sprockets.database.sqlite.DbOpenHelper.java
/** * Execute the statements in the resource script on the database. Each statement must end with a * semicolon.// ww w . j a va 2s. co m */ private void execScript(SQLiteDatabase db, Resources res, int script) throws IOException { LineIterator lines = IOUtils.lineIterator(res.openRawResource(script), UTF_8); StringBuilder sql = new StringBuilder(2048); // enough capacity for a long statement try { // read each (potentially multi-line) statement and execute them one at a time while (lines.hasNext()) { String line = lines.next().trim(); int length = line.length(); if (length > 0) { sql.append(line).append("\n"); if (line.charAt(length - 1) == ';') { // statement loaded db.execSQL(sql.toString()); sql.setLength(0); // reset builder for a new statement } } } } finally { lines.close(); } }
From source file:org.ohmage.db.DbHelper.java
public void clearAll(SQLiteDatabase db) { db.execSQL("DROP TABLE IF EXISTS " + Tables.CAMPAIGNS); db.execSQL("DROP TABLE IF EXISTS " + Tables.SURVEYS); db.execSQL("DROP TABLE IF EXISTS " + Tables.SURVEY_PROMPTS); db.execSQL("DROP TABLE IF EXISTS " + Tables.RESPONSES); db.execSQL("DROP TABLE IF EXISTS " + Tables.PROMPT_RESPONSES); onCreate(db);//from ww w .j av a 2 s. c om }
From source file:com.dm.material.dashboard.candybar.databases.Database.java
private void resetDatabase(SQLiteDatabase db) { Cursor cursor = db.rawQuery("SELECT name FROM sqlite_master WHERE type=\'table\'", null); SparseArrayCompat<String> tables = new SparseArrayCompat<>(); if (cursor.moveToFirst()) { do {//from ww w . j av a 2 s .c o m tables.append(tables.size(), cursor.getString(0)); } while (cursor.moveToNext()); } cursor.close(); for (int i = 0; i < tables.size(); i++) { try { String dropQuery = "DROP TABLE IF EXISTS " + tables.get(i); if (!tables.get(i).equalsIgnoreCase("SQLITE_SEQUENCE")) db.execSQL(dropQuery); } catch (Exception ignored) { } } onCreate(db); }
From source file:com.nookdevs.library.FictionwiseBooks.java
@Override public void onCreate(SQLiteDatabase db) { try {/*from w w w . j av a 2s. c o m*/ db.execSQL(CREATE_BOOKS_TABLE); db.execSQL(CREATE_USER_TABLE); } catch (Exception ex) { Log.e("FictionwiseBooks", "exception while creating ficionwise tables", ex); } }
From source file:com.snt.bt.recon.database.DBHandler.java
public void updateTripEnd(UUID sessionId, String timestamp) { SQLiteDatabase database = this.getWritableDatabase(); String updateQuery = "UPDATE " + TABLE_TRIPS + " set " + KEY_TIMESTAMP_END + " = '" + timestamp + "' where " + KEY_SESSION_ID + "=" + "'" + sessionId + "'"; //Log.d("DatabaseTest", updateQuery); database.execSQL(updateQuery); database.close();//from w w w .j a v a 2 s. c o m }
From source file:com.nookdevs.library.FictionwiseBooks.java
@Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { try {//from w ww . ja v a 2s . c o m db.execSQL("ALTER TABLE BOOKS ADD COLUMN STATUS TEXT"); } catch (Exception ex) { onCreate(db); } }
From source file:com.openerp.support.calendar.OECalendar.java
/** * Update the status of synced events in crm.meeting table. * /*from w w w . j a v a 2 s . c o m*/ * @param meeting_id * : record id of the crm.meeting. * @param calendar_id * : under which meeting synced. * @param event_id * : creted event id under calendar. * @param sync * : true, if synced in OpenERP Mobile calendar. */ public void update_SyncedEvent(int meeting_id, String calendar_id, String event_id, String sync) { db = new MeetingDBHelper(context); SQLiteDatabase database = db.getWritableDatabase(); String query = "update " + db.getTableName() + " set in_cal_sync = '" + sync + "',calendar_event_id = '" + event_id + "', calendar_id = '" + calendar_id + "' where id = " + meeting_id; database.execSQL(query); database.close(); }
From source file:com.snt.bt.recon.database.DBHandler.java
public void deleteOldTrips(UUID sessionId) { SQLiteDatabase database = this.getWritableDatabase(); String updateQuery = "DELETE FROM " + TABLE_TRIPS + " where " + KEY_SESSION_ID + "!=" + "'" + sessionId + "' and " + KEY_UPLOAD_STATUS + " != '" + "no" + "'"; //Delete if partial or yes //Log.d("DatabaseTest", updateQuery); database.execSQL(updateQuery); database.close();/*from w w w. j a v a 2 s . com*/ }