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.alchemiasoft.common.content.BookDBOpenHelper.java

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    try {//from w w  w.  ja v  a  2s.  c  o  m
        db.beginTransaction();

        db.execSQL(BookDB.Book.DELETE_TABLE);

        onCreate(db);

        db.setTransactionSuccessful();
        Log.i(TAG_LOG, "Successfully upgraded " + BookDB.NAME);
    } catch (Exception e) {
        Log.e(TAG_LOG, "Error creating " + BookDB.NAME + ": ", e);
    } finally {
        db.endTransaction();
    }
}

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

public static void banUser(String decodedfrom, Context context) {
    DBHelper db = new DBHelper(context);
    SQLiteDatabase dbwrite = db.getWritableDatabase();

    Cursor c = dbwrite.rawQuery("SELECT _id FROM banned_users " + " WHERE name=" + esc(decodedfrom), null);

    if (c.getCount() > 0) {
        c.moveToFirst();/*from   w w  w . ja va 2  s . c o m*/
        dbwrite.execSQL("UPDATE banned_users SET bandisabled=0 WHERE _id=" + c.getInt(0));
    } else {
        ContentValues cv = new ContentValues();
        cv.put("name", decodedfrom);
        cv.put("bandisabled", 0);
        dbwrite.insert("banned_users", null, cv);
    }

    // Mark all the user posts as read, so they get deleted later
    dbwrite.execSQL("UPDATE headers SET read=1, read_unixdate=" + System.currentTimeMillis()
            + " WHERE from_header=" + esc(decodedfrom));

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

From source file:it.ms.theing.loquitur.functions.Storage.java

@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
    sqLiteDatabase.execSQL(
            "create table if not exists alias ( genre text not null , key text not null , value text not null ,UNIQUE (genre, key) ON CONFLICT REPLACE)");
    sqLiteDatabase.execSQL("create index if not exists alias_key on alias ( key )");
    sqLiteDatabase.execSQL("create index if not exists alias_genre on alias ( genre )");
}

From source file:net.xisberto.work_schedule.database.Database.java

@Override
public void onCreate(SQLiteDatabase db) {
    db.execSQL(TablePeriod.CREATE_TABLE);
}

From source file:net.nordist.lloydproof.CorrectionStorage.java

@Override
public void onCreate(SQLiteDatabase database) {
    Log.w(TAG, "Creating database v" + DATABASE_VERSION);
    database.execSQL("CREATE TABLE " + TABLE_NAME + " (id integer PRIMARY KEY AUTOINCREMENT,"
            + " current_text text NOT NULL DEFAULT '');");
}

From source file:company.test.Test.java

public void onDoneButtonClick(View view) {
    View v = (View) view.getParent();
    TextView taskTextView = (TextView) v.findViewById(R.id.taskTextView);
    String task = taskTextView.getText().toString();

    String sql = String.format("DELETE FROM %s WHERE %s = '%s'", ItemContract.TABLE, ItemContract.Columns.ITEM,
            task);//  w ww  .ja v  a2 s  .  co m

    SQLiteDatabase sqlDB = helper.getWritableDatabase();
    sqlDB.execSQL(sql);
    updateUI();
    retrieveGl();
}

From source file:com.jbirdvegas.mgerrit.database.Revisions.java

@Override
public void create(String TAG, SQLiteDatabase db) {
    // Specify a conflict algorithm here so we don't have to worry about it later
    db.execSQL("create table " + TABLE + " (" + C_CHANGE_ID + " text PRIMARY KEY ON CONFLICT REPLACE, "
            + C_PATCH_SET_NUMBER + " INTEGER NOT NULL, " + C_COMMIT + " text, " + C_AUTHOR + " TEXT ,"
            + C_COMMITTER + " TEXT, " + C_MESSAGE + " text, " + "FOREIGN KEY (" + C_CHANGE_ID + ") REFERENCES "
            + Changes.TABLE + "(" + Changes.C_CHANGE_ID + "), " + "FOREIGN KEY (" + C_AUTHOR + ") REFERENCES "
            + Users.TABLE + "(" + Users.C_ACCOUNT_ID + "), " + "FOREIGN KEY (" + C_COMMITTER + ") REFERENCES "
            + Users.TABLE + "(" + Users.C_ACCOUNT_ID + "))");
}

From source file:me.jreilly.JamesTweet.Adapters.TweetDataHelper.java

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

From source file:com.liferay.alerts.database.DatabaseHelper.java

public void onOpen(SQLiteDatabase database) {
    super.onOpen(database);

    database.execSQL(_FOREIGN_KEYS_ON);
}

From source file:com.citrus.sdk.database.DBHandler.java

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    db.execSQL("DROP TABLE IF EXISTS " + PAYOPTION_TABLE);
    db.execSQL("DROP TABLE IF EXISTS " + BANK_TABLE);
    onCreate(db);/*  www .  jav a2 s.c  o  m*/
}