Example usage for android.database.sqlite SQLiteDatabase execSQL

List of usage examples for android.database.sqlite SQLiteDatabase execSQL

Introduction

In this page you can find the example usage for android.database.sqlite SQLiteDatabase execSQL.

Prototype

public void execSQL(String sql) throws SQLException 

Source Link

Document

Execute a single SQL statement that is NOT a SELECT or any other SQL statement that returns data.

Usage

From source file:com.shalzz.attendance.DatabaseHandler.java

/**
 * Create Table.//www.  j a va2s .  c  o  m
 */
@Override
public void onCreate(SQLiteDatabase db) {
    db.execSQL(Subject.CREATE_TABLE);
    db.execSQL(Period.CREATE_TABLE);
    db.execSQL(User.CREATE_TABLE);
    db.execSQL(AbsentDate.CREATE_TABLE);
}

From source file:au.org.ala.fielddata.mobile.dao.DatabaseHelper.java

private void version3(SQLiteDatabase db) {
    if (Utils.DEBUG) {
        Log.i("DatabaseHelper", "Upgrading to version 3 of the schema");
    }/*from  w w w.  j  av a  2 s.c o  m*/

    db.execSQL("DROP TABLE " + Species.class.getSimpleName());
    createSpeciesTables(db);
}

From source file:com.cloudmine.api.db.RequestDBOpenHelper.java

private void createDatabase(SQLiteDatabase sqLiteDatabase) {
    sqLiteDatabase.execSQL(REQUEST_DATABASE_CREATE);
    sqLiteDatabase.execSQL(HEADER_DATABASE_CREATE);
}

From source file:com.cloudmine.api.db.RequestDBOpenHelper.java

private void dropDatabase(SQLiteDatabase sqLiteDatabase) {
    sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + HEADER_DATABASE_TABLE);
    sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + REQUEST_DATABASE_TABLE);
}

From source file:org.mozilla.gecko.sync.repositories.android.AndroidBrowserHistoryDataExtender.java

@Override
public void onCreate(SQLiteDatabase db) {
    String createTableSql = "CREATE TABLE " + TBL_HISTORY_EXT + " (" + COL_GUID + " TEXT PRIMARY KEY, "
            + COL_VISITS + " TEXT)";
    db.execSQL(createTableSql);
}

From source file:au.org.ala.fielddata.mobile.dao.DatabaseHelper.java

private void version4(SQLiteDatabase db) {
    if (Utils.DEBUG) {
        Log.i("DatabaseHelper", "Upgrading to version 4 of the schema");
    }/*from w ww.  j  av a2  s  . co m*/
    db.execSQL("ALTER TABLE " + SpeciesDAO.SPECIES_GROUP_TABLE + " RENAME TO OLD_SPECIES_GROUP");
    db.execSQL(SpeciesDAO.SPECIES_GROUP_DDL);
    createSpeciesIndexes(db);

    db.execSQL("INSERT INTO " + SpeciesDAO.SPECIES_GROUP_TABLE
            + " (server_id, name, parent_group_id) select parent_group_id, name, parent_group_id from OLD_SPECIES_GROUP");
    db.execSQL("DROP TABLE OLD_SPECIES_GROUP");

    createRecordIndexes(db);
    createAttributeRowTable(db);
    db.execSQL("ALTER TABLE " + RecordDAO.ATTRIBUTE_VALUE_TABLE + " ADD COLUMN row_id INTEGER");

}

From source file:org.jsharkey.oilcan.ScriptDatabase.java

public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    int currentVersion = oldVersion;

    if (currentVersion != newVersion) {
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_SCRIPTS);
        onCreate(db);/*www.  j  a v  a  2  s  .  c om*/
    }
}

From source file:com.seneca.android.senfitbeta.DbHelper.java

@Override
public void onCreate(SQLiteDatabase db) {
    db.execSQL(CREATE_TABLE_USERS);
    db.execSQL(CREATE_TABLE_EXERCISE);/*from  ww  w. ja va 2s .c om*/
    db.execSQL(CREATE_TABLE_RIP);
    db.execSQL(CREATE_TABLE_IMAGES);
    db.execSQL(CREATE_TABLE_CALL);

}

From source file:za.co.neilson.alarm.database.Database.java

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    db.execSQL("DROP TABLE IF EXISTS " + ALARM_TABLE);
    onCreate(db);//  ww  w  .  j av a  2 s . c  om
}

From source file:com.almarsoft.GroundhogReader.lib.DBUtils.java

public static void banThread(String group, String clean_subject, Context context) {
    int groupid = getGroupIdFromName(group, context);

    DBHelper db = new DBHelper(context);
    SQLiteDatabase dbwrite = db.getWritableDatabase();

    // First, check if it already is on the banned_threads table (it could be with unbanned=1)
    Cursor c = dbwrite.rawQuery("SELECT _id FROM banned_threads " + " WHERE subscribed_group_id=" + groupid
            + " AND clean_subject=" + esc(clean_subject), null);

    if (c.getCount() > 0) { // Existed
        c.moveToFirst();//from  ww w . jav a2s .com
        dbwrite.execSQL("UPDATE banned_threads SET bandisabled=0 WHERE _id=" + c.getInt(0));

    } else {
        // New troll goes down to the pit
        ContentValues cv = new ContentValues();
        cv.put("subscribed_group_id", groupid);
        cv.put("bandisabled", 0);
        cv.put("clean_subject", clean_subject);
        dbwrite.insert("banned_threads", null, cv);
    }

    // Mark all the messages from the thread as read so they get cleaned later
    dbwrite.execSQL("UPDATE headers SET read=1, read_unixdate=" + System.currentTimeMillis()
            + " WHERE subscribed_group_id=" + groupid + " AND clean_subject=" + esc(clean_subject));

    c.close();
    dbwrite.close();
    db.close();
}