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.adguard.android.db.DbHelper.java

private void executeSql(SQLiteDatabase db, String script) {
    for (String sql : StringUtils.split(script, ";")) {
        if (!StringUtils.isWhitespace(sql)) {
            LOG.info("Execute sql: {}", sql);
            db.execSQL(sql);
        }/*ww  w  .  jav a  2s  .  com*/
    }
}

From source file:net.willwebberley.gowertides.utils.WeatherDatabase.java

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    System.out.println("upgrading db");
    db.execSQL("DROP TABLE IF EXISTS weather");
    db.execSQL("DROP TABLE IF EXISTS surf");
    onCreate(db);//w w w  .  ja  v a  2 s  .c o  m
}

From source file:github.popeen.dsub.util.SongDBHandler.java

@Override
public void onCreate(SQLiteDatabase db) {
    db.execSQL("CREATE TABLE " + TABLE_SONGS + " ( " + SONGS_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
            + SONGS_SERVER_KEY + " INTEGER NOT NULL, " + SONGS_SERVER_ID + " TEXT NOT NULL, "
            + SONGS_COMPLETE_PATH + " TEXT NOT NULL, " + SONGS_LAST_PLAYED + " INTEGER, " + SONGS_LAST_COMPLETED
            + " INTEGER, " + "UNIQUE(" + SONGS_SERVER_KEY + ", " + SONGS_SERVER_ID + "))");
}

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

@Override
public void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion) {
    Log.w(TAG, "Upgrading database from v" + oldVersion + " to v" + newVersion
            + ", which will destroy all old data");
    database.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME + ";");
    onCreate(database);/*from   w w  w  . j  ava  2 s  .c om*/
}

From source file:com.hufeiya.SignIn.persistence.TopekaDatabaseHelper.java

@Override
public void onCreate(SQLiteDatabase db) {
    /*//from w  w  w . ja  v a  2s .co m
     * create the category table first, as quiz table has a foreign key
     * constraint on category id
     */
    db.execSQL(CategoryTable.CREATE);
    preFillDatabase(db);
}

From source file:com.github.gfx.android.orma.example.activity.MainActivity.java

public void setupV1Database() {
    deleteDatabase(DB_NAME);//from   w ww.  j a  va2s  . c o  m
    SQLiteDatabase db = openOrCreateDatabase(DB_NAME, 0, null);
    db.setVersion(1);
    db.execSQL("CREATE TABLE todos (id INTEGER PRIMARY KEY, note TEXT NOT NULL)");
    db.execSQL("CREATE INDEX index_note_on_todos ON todos (note)");
    db.execSQL("INSERT INTO todos (note) values ('todo v1 #1'), ('todo v1 #2')");
    db.close();
}

From source file:github.popeen.dsub.util.SongDBHandler.java

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    db.execSQL("DROP TABLE IF EXISTS " + TABLE_SONGS);
    this.onCreate(db);
}

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

private void version2(SQLiteDatabase db) {
    if (Utils.DEBUG) {
        Log.i("DatabaseHelper", "Upgrading to version 2 of the schema");
    }// w ww  .j a  v a  2 s.c o m
    db.execSQL("DROP TABLE " + Record.class.getSimpleName());
    createRecordTable(db);
}

From source file:com.google.android.apps.santatracker.data.DestinationDbHelper.java

public void reinitialise() {
    SQLiteDatabase db = getWritableDatabase();
    // delete all entries
    db.execSQL(SQL_DELETE_ENTRIES);

    onCreate(db);/*from  w w  w.  j  a  v  a  2s  .  c  o  m*/

    db.close();
}

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

@Override
public void onCreate(SQLiteDatabase db) {
    try {/*from   ww  w . jav  a2 s  .  com*/
        db.beginTransaction();

        for (String table : TABLES) {
            db.execSQL("CREATE TABLE " + table + " (_id INTEGER PRIMARY KEY AUTOINCREMENT, server_id INTEGER, "
                    + "created INTEGER, updated INTEGER, last_sync INTEGER" + "name TEXT, json TEXT)");

            createServerIdIndex(db, table);
        }

        createRecordTable(db);
        createSpeciesTables(db);
        createAttributeRowTable(db);

        db.setTransactionSuccessful();
    } finally {
        db.endTransaction();
    }

}