List of usage examples for android.database.sqlite SQLiteDatabase endTransaction
public void endTransaction()
From source file:com.contentful.vault.SqliteHelper.java
@Override public void onCreate(SQLiteDatabase db) { db.beginTransaction();/*from w w w . j a va 2 s . com*/ 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 v a 2 s . c o m*/ 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 {//from www. java2s . c om 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:ru.ming13.gambit.database.DatabaseOperator.java
private void deleteDatabaseContents(SQLiteDatabase database) { try {//from ww w. java 2s . c om 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.hemou.android.core.sync.persistence.DatabaseCache.java
public <Key, E> void del(PersistableResource<E> persistableResource, Key... keys) { if (keys == null || keys.length == 0) return;/*from ww w. j a v a2s . 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;//from ww w .j av a2s. co 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(); } }
From source file:com.futureplatforms.kirin.extensions.databases.DatabasesBackend.java
protected void endNativeTransaction(SQLiteDatabase db) { db.endTransaction(); }
From source file:au.org.ala.fielddata.mobile.dao.DatabaseHelper.java
public synchronized void doInTransaction(UpdateWork work) { SQLiteDatabase db = getWritableDatabase(); try {/* w w w .j a v a2 s. c om*/ db.beginTransaction(); work.doUpdate(); db.setTransactionSuccessful(); } finally { if (db != null) { db.endTransaction(); close(); } } }
From source file:com.hemou.android.core.sync.persistence.DatabaseCache.java
private <E> List<E> requestAndStore(final SQLiteOpenHelper helper, final PersistableResource<E> persistableResource) throws IOException { List<E> items = null;//from w w w . j a v a 2 s . c o m try { items = persistableResource.request(); } catch (ExpiredAuthorizationException e) { return new ArrayList<E>(); } final SQLiteDatabase db = getWritable(helper); if (db == null) return items; db.beginTransaction(); try { persistableResource.store(db, items); db.setTransactionSuccessful(); } finally { db.endTransaction(); } return items; }
From source file:com.adguard.android.db.DbHelper.java
@Override public void onCreate(SQLiteDatabase db) { LOG.info("DbHelper.onCreate()"); try {/*w w w . j a v a2s . c o m*/ db.beginTransaction(); createTables(db); fillFilters(db); fillFiltersLocalization(db); enableDefaultFilters(db); db.setTransactionSuccessful(); } finally { if (db.inTransaction()) { db.endTransaction(); } } }