Android SqliteDatabase Command executeSqlStatementsInTx(SQLiteDatabase db, String[] statements)

Here you can find the source of executeSqlStatementsInTx(SQLiteDatabase db, String[] statements)

Description

execute Sql Statements In Tx

License

Open Source License

Declaration

public static int executeSqlStatementsInTx(SQLiteDatabase db,
            String[] statements) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import android.database.sqlite.*;

public class Main {
    public static int executeSqlStatementsInTx(SQLiteDatabase db,
            String[] statements) {
        db.beginTransaction();/*from ww  w  .j  a  v  a  2  s .  c  o  m*/
        try {
            int count = executeSqlStatements(db, statements);
            db.setTransactionSuccessful();
            return count;
        } finally {
            db.endTransaction();
        }
    }

    public static int executeSqlStatements(SQLiteDatabase db,
            String[] statements) {
        int count = 0;
        for (String line : statements) {
            line = line.trim();
            if (line.length() > 0) {
                db.execSQL(line);
                count++;
            }
        }
        return count;
    }
}

Related

  1. executeSqlStatements(SQLiteDatabase db, String[] statements)
  2. getListOfDays(SQLiteDatabase db)
  3. insertIntoTable(SQLiteDatabase database, String table, String[] data)
  4. selectFromTable(SQLiteDatabase db, String table, String sample)
  5. updateTable(SQLiteDatabase database, String table, String id, String[] newValues)