Example usage for android.database.sqlite SQLiteDatabase setTransactionSuccessful

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

Introduction

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

Prototype

public void setTransactionSuccessful() 

Source Link

Document

Marks the current transaction as successful.

Usage

From source file:edu.htl3r.schoolplanner.backend.database.AutoSelectDatabase.java

private void deleteAllRowsFromDatabaseTransaction(String table, String loginSetKey) {
    SQLiteDatabase database = this.database.openDatabase(true);
    database.beginTransaction();//from www .  j a  v a2  s.c  om

    this.database.deleteAllRowsWithLoginSetKey(database, table, loginSetKey);

    database.setTransactionSuccessful();
    database.endTransaction();
    this.database.closeDatabase(database);
}

From source file:com.alchemiasoft.common.content.BookDBOpenHelper.java

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    try {//from w  w  w.j  a v a  2 s.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.contentful.vault.SqliteHelper.java

@Override
public void onCreate(SQLiteDatabase db) {
    db.beginTransaction();//from w w w .j ava  2s . c o m
    try {
        execCreate(spaceHelper, db);
        db.setTransactionSuccessful();
    } finally {
        db.endTransaction();
    }
}

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

private void preFillDatabase(SQLiteDatabase db) {
    try {//from   w  w  w.  j  a  va  2  s  . com
        db.beginTransaction();
        try {
            fillCategoriesAndQuizzes(db);
            db.setTransactionSuccessful();
        } finally {
            db.endTransaction();
        }
    } catch (IOException | JSONException e) {
        Log.e(TAG, "preFillDatabase", e);
    }
}

From source file:nerd.tuxmobil.fahrplan.congress.FahrplanMisc.java

public static void writeHighlight(Context context, Lecture lecture) {
    HighlightDBOpenHelper highlightDB = new HighlightDBOpenHelper(context);

    SQLiteDatabase db = highlightDB.getWritableDatabase();

    try {/* www  . ja  va  2  s.  co  m*/
        db.beginTransaction();
        db.delete(HighlightsTable.NAME, HighlightsTable.Columns.EVENT_ID + "=?",
                new String[] { lecture.lecture_id });

        ContentValues values = new ContentValues();

        values.put(HighlightsTable.Columns.EVENT_ID, Integer.parseInt(lecture.lecture_id));
        int highlightState = lecture.highlight ? HighlightsTable.Values.HIGHLIGHT_STATE_ON
                : HighlightsTable.Values.HIGHLIGHT_STATE_OFF;
        values.put(HighlightsTable.Columns.HIGHLIGHT, highlightState);

        db.insert(HighlightsTable.NAME, null, values);
        db.setTransactionSuccessful();
    } catch (SQLException e) {
    } finally {
        db.endTransaction();
        db.close();
    }
}

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

public synchronized void doInTransaction(UpdateWork work) {

    SQLiteDatabase db = getWritableDatabase();
    try {/*from   w w  w  .j  a v a  2s .co m*/
        db.beginTransaction();

        work.doUpdate();

        db.setTransactionSuccessful();
    } finally {
        if (db != null) {
            db.endTransaction();
            close();
        }
    }
}

From source file:ru.ming13.gambit.database.DatabaseOperator.java

private void deleteDatabaseContents(SQLiteDatabase database) {
    try {/*from w ww.java2  s  .  c o m*/
        database.beginTransaction();

        database.execSQL(SqlBuilder.buildDeletionClause(DatabaseSchema.Tables.CARDS));
        database.execSQL(SqlBuilder.buildDeletionClause(DatabaseSchema.Tables.DECKS));

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

From source file:com.adguard.android.db.DbHelper.java

@Override
public void onCreate(SQLiteDatabase db) {
    LOG.info("DbHelper.onCreate()");
    try {/*from  www. j  ava  2s.  co  m*/
        db.beginTransaction();

        createTables(db);
        fillFilters(db);
        fillFiltersLocalization(db);
        enableDefaultFilters(db);

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

From source file:com.hemou.android.core.sync.persistence.DatabaseCache.java

public <Key, E> void del(PersistableResource<E> persistableResource, Key... keys) {
    if (keys == null || keys.length == 0)
        return;//  w  w w.  j a v a  2s.c  o m
    SQLiteOpenHelper helper = helperProvider.get();
    final SQLiteDatabase db = getWritable(helper);
    if (db == null)
        return;

    db.beginTransaction();
    try {
        persistableResource.del(db, keys);
        db.setTransactionSuccessful();
    } finally {
        db.endTransaction();
        helper.close();
    }
}

From source file:com.hemou.android.core.sync.persistence.DatabaseCache.java

public <E> void add(PersistableResource<E> persistableResource, E... datas) {
    if (datas == null || datas.length == 0)
        return;/*www.j  a v  a  2 s .c o  m*/
    SQLiteOpenHelper helper = helperProvider.get();
    final SQLiteDatabase db = getWritable(helper);
    if (db == null)
        return;

    db.beginTransaction();
    try {
        persistableResource.add(db, datas);
        db.setTransactionSuccessful();
    } finally {
        db.endTransaction();
        helper.close();
    }
}