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:Main.java

public static void dropTable(SQLiteDatabase db) {
    db.execSQL("DROP TABLE IF EXISTS " + TABLE_CONTENT_HELP);
}

From source file:Main.java

static void create(SQLiteDatabase db) {
    db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
    db.execSQL("CREATE TABLE [cache_data] ( " + " [set_name] TEXT,  " + " [value] TEXT,  " + " [tag] TEXT);");
}

From source file:Main.java

public static void vacuum(SQLiteDatabase db) {
    db.execSQL("VACUUM");
}

From source file:Main.java

static public void clearHistory(SQLiteDatabase db) {
    db.execSQL("DROP TABLE IF EXISTS " + TABLE_HISTORY);
    createHistoryTable(db);// w w  w  .  java  2s  . c o m
}

From source file:Main.java

private static void createAppApk(SQLiteDatabase db) {
    db.execSQL(CREATE_TABLE_APP);
    db.execSQL("create index app_id on " + TABLE_APP + " (id);");
    db.execSQL(CREATE_TABLE_APK);//from  ww w .  ja  v a 2s .com
    db.execSQL("create index apk_vercode on " + TABLE_APK + " (vercode);");
    db.execSQL("create index apk_id on " + TABLE_APK + " (id);");
}

From source file:Main.java

public static void deleteTable(final SQLiteDatabase db, final String tableName) {
    db.execSQL("DROP TABLE IF EXISTS " + tableName);
}

From source file:Main.java

public static void dropTable(SQLiteDatabase db, String tab) {
    try {// w ww .  ja v  a  2s  .co m
        db.execSQL(new StringBuilder(64).append("DROP TABLE IF EXISTS ").append(tab).append(';').toString());
    } catch (Throwable e) {
        e.printStackTrace();
    }
}

From source file:Main.java

private static void executeStatements(SQLiteDatabase database, List<String> statements) {
    try {//  www .  j  a  va  2 s  .  c  o  m
        database.beginTransaction();
        for (String statement : statements) {
            database.execSQL(statement);
        }
        database.setTransactionSuccessful();
    } finally {
        database.endTransaction();
    }
}

From source file:Main.java

public static int executeSqlStatements(SQLiteDatabase db, String[] statements) {
    int count = 0;
    for (String line : statements) {
        line = line.trim();//ww w . j ava  2  s. c  o  m
        if (line.length() > 0) {
            db.execSQL(line);
            count++;
        }
    }
    return count;
}

From source file:Main.java

public static boolean updateItemState(SQLiteDatabase db, Integer id, Integer new_state) {
    String update_query = "UPDATE " + TABLE_NAME + " SET " + COLUMN_STATE + " = " + new_state + " WHERE "
            + COLUMN_ID + " = " + id;
    db.execSQL(update_query);
    return true;// ww  w . ja  v  a2s  .  co  m
}