List of usage examples for android.database.sqlite SQLiteDatabase execSQL
public void execSQL(String sql) throws SQLException
From source file:com.almarsoft.GroundhogReader.lib.DBUtils.java
public static void setGroupAllRead(String group, Context context) { int groupid = getGroupIdFromName(group, context); DBHelper dbhelper = new DBHelper(context); SQLiteDatabase dbwriter = dbhelper.getWritableDatabase(); dbwriter.execSQL("UPDATE headers SET read=1, read_unixdate=" + System.currentTimeMillis() + " WHERE subscribed_group_id=" + groupid); dbwriter.close();//from w ww . j av a2 s .c om dbhelper.close(); }
From source file:com.almarsoft.GroundhogReader.lib.DBUtils.java
public static void markAsRead(String msgId, Context context) { if (msgId != null) { DBHelper dbhelper = new DBHelper(context); SQLiteDatabase dbwriter = dbhelper.getWritableDatabase(); dbwriter.execSQL("UPDATE headers SET read=1, read_unixdate=" + System.currentTimeMillis() + " WHERE server_article_id=" + esc(msgId)); dbwriter.close();/*from w ww . jav a2 s . co m*/ dbhelper.close(); } }
From source file:com.almarsoft.GroundhogReader.lib.DBUtils.java
public static void markAsUnread(String msgId, Context context) { if (msgId != null) { DBHelper dbhelper = new DBHelper(context); SQLiteDatabase dbwriter = dbhelper.getWritableDatabase(); dbwriter.execSQL("UPDATE headers SET read=0, read_unixdate=0 WHERE server_article_id=" + esc(msgId)); dbwriter.close();/* w w w . j av a2 s .co m*/ dbhelper.close(); } }
From source file:org.liberty.android.fantastischmemopro.DatabaseHelper.java
public static void createEmptyDatabase(String path, String name) throws IOException, SQLException { File dbfile = new File(path + "/" + name); if (dbfile.exists()) { // throw new IOException("DB already exist"); /* Create a backup and overwrite it instead poping up an error */ File backupFile = new File(dbfile.getAbsolutePath().replaceAll(".db$", ".old.db")); if (backupFile.exists()) { backupFile.delete();//from w w w . j a v a 2s .c o m } dbfile.renameTo(backupFile); } SQLiteDatabase database = SQLiteDatabase.openDatabase(path + "/" + name, null, SQLiteDatabase.OPEN_READWRITE | SQLiteDatabase.CREATE_IF_NECESSARY); database.execSQL( "CREATE TABLE dict_tbl(_id INTEGER PRIMARY KEY ASC AUTOINCREMENT, question TEXT, answer TEXT, note TEXT, category TEXT)"); database.execSQL( "CREATE TABLE learn_tbl(_id INTEGER PRIMARY KEY ASC AUTOINCREMENT, date_learn, interval, grade INTEGER, easiness REAL, acq_reps INTEGER, ret_reps INTEGER, lapses INTEGER, acq_reps_since_lapse INTEGER, ret_reps_since_lapse INTEGER)"); database.execSQL("CREATE TABLE control_tbl(ctrl_key TEXT, value TEXT)"); database.beginTransaction(); try { database.execSQL("DELETE FROM learn_tbl"); database.execSQL("INSERT INTO learn_tbl(_id) SELECT _id FROM dict_tbl"); database.execSQL( "UPDATE learn_tbl SET date_learn = '2010-01-01', interval = 0, grade = 0, easiness = 2.5, acq_reps = 0, ret_reps = 0, lapses = 0, acq_reps_since_lapse = 0, ret_reps_since_lapse = 0"); database.execSQL("INSERT INTO control_tbl(ctrl_key, value) VALUES('question_locale', 'US')"); database.execSQL("INSERT INTO control_tbl(ctrl_key, value) VALUES('answer_locale', 'US')"); database.execSQL("INSERT INTO control_tbl(ctrl_key, value) VALUES('question_align', 'center')"); database.execSQL("INSERT INTO control_tbl(ctrl_key, value) VALUES('answer_align', 'center')"); database.execSQL("INSERT INTO control_tbl(ctrl_key, value) VALUES('question_font_size', '24')"); database.execSQL("INSERT INTO control_tbl(ctrl_key, value) VALUES('answer_font_size', '24')"); database.setTransactionSuccessful(); } finally { database.endTransaction(); database.close(); } }
From source file:com.manning.androidhacks.hack023.provider.DatabaseHelper.java
@Override public void onCreate(SQLiteDatabase db) { db.execSQL("CREATE TABLE " + TodoContentProvider.TODO_TABLE_NAME + " (" + TodoContentProvider.COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + TodoContentProvider.COLUMN_SERVER_ID + " INTEGER," + TodoContentProvider.COLUMN_TITLE + " LONGTEXT," + TodoContentProvider.COLUMN_STATUS_FLAG + " INTEGER" + ");"); }
From source file:com.manning.androidhacks.hack042.db.DatabaseHelper.java
@Override public void onCreate(SQLiteDatabase db) { db.execSQL("CREATE TABLE " + "pois (" + "_id INTEGER PRIMARY KEY AUTOINCREMENT," + "title TEXT," + "longitude FLOAT," + "latitude FLOAT);"); }
From source file:com.manning.androidhacks.hack043.provider.DatabaseHelper.java
@Override public void onCreate(SQLiteDatabase db) { db.execSQL("CREATE TABLE " + NoBatchNumbersContentProvider.TABLE_NAME + " (" + NoBatchNumbersContentProvider.COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + NoBatchNumbersContentProvider.COLUMN_TEXT + " TEXT" + ");"); db.execSQL("CREATE TABLE " + BatchNumbersContentProvider.TABLE_NAME + " (" + BatchNumbersContentProvider.COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + BatchNumbersContentProvider.COLUMN_TEXT + " TEXT" + ");"); db.execSQL("CREATE TABLE " + MySQLContentProvider.TABLE_NAME + " (" + MySQLContentProvider.COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + MySQLContentProvider.COLUMN_TEXT + " TEXT" + ");"); }
From source file:DictionaryDatabase.java
@Override public void onCreate(SQLiteDatabase db) { db.execSQL("CREATE TABLE " + TABLE_DICTIONARY + "(_id integer PRIMARY KEY," + FIELD_WORD + " TEXT, " + FIELD_DEFINITION + " TEXT);"); }
From source file:com.almarsoft.GroundhogReader.lib.DBUtils.java
/** * Unsubscribe a group, deleting from the DB the headers and from the disk the group's directory storage * for bodies and attachments./*from ww w . ja va 2 s . c o m*/ * */ public static void unsubscribeGroup(String group, Context context) { int groupid = getGroupIdFromName(group, context); if (groupid == -1) return; DBHelper db = new DBHelper(context); SQLiteDatabase dbWrite = db.getWritableDatabase(); String query = "DELETE FROM subscribed_groups WHERE _ID=" + groupid; dbWrite.execSQL(query); query = "DELETE FROM headers WHERE subscribed_group_id=" + groupid; dbWrite.execSQL(query); dbWrite.close(); db.close(); FSUtils.deleteDirectory( UsenetConstants.EXTERNALSTORAGE + "/" + UsenetConstants.APPNAME + "/offlinecache/groups/" + group); FSUtils.deleteDirectory(UsenetConstants.EXTERNALSTORAGE + "/" + UsenetConstants.APPNAME + "/" + UsenetConstants.ATTACHMENTSDIR + "/" + group); }
From source file:com.manning.androidhacks.hack043.provider.DatabaseHelper.java
@Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + NoBatchNumbersContentProvider.TABLE_NAME); db.execSQL("DROP TABLE IF EXISTS " + BatchNumbersContentProvider.TABLE_NAME); db.execSQL("DROP TABLE IF EXISTS " + MySQLContentProvider.TABLE_NAME); onCreate(db);//from w w w.ja v a 2 s .c o m }