SQLiteDatabase endTransaction - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for SQLiteDatabase endTransaction method.

This code example shows how to use the following methods: beginTransaction, endTransaction, setTransactionSuccessful
 
        final SQLiteDatabase db = getWritable(helper);
        if (db == null)
            return items;
 
        db.beginTransaction();
        try { 
            persistableResource.store(db, items);
            db.setTransactionSuccessful();
        } finally { 
            db.endTransaction();
        } 
        return items;
    } 
 
    private <E> List<E> loadFromDB(final SQLiteOpenHelper helper,
            final PersistableResource<E> persistableResource) {
        final SQLiteDatabase db = getReadable(helper);
        if (db == null)
            return null; 
Full Snippet Info
9
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: beginTransaction, endTransaction, setTransactionSuccessful, update
    @Override 
    public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
        SQLiteDatabase db = null;
        try { 
            db = mDatabaseHelper.getWritableDatabase();
            db.beginTransaction();
 
            String newSelection = buildSelection(uri, selection);
            int count = db.update("tests", values, newSelection, selectionArgs);
            db.setTransactionSuccessful();
            return count;
        } finally { 
            if (db != null) {
                db.endTransaction();
            } 
        } 
    } 
 
    private String buildSelection(Uri uri, String selection) {
        long id = 0;
Full Snippet Info
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: beginTransaction, delete, endTransaction, setTransactionSuccessful
            file = new File(getLockPatternFilename(userId));
            if (file.exists()) {
                file.delete();
            } 
 
            db.beginTransaction();
            db.delete(TABLE, COLUMN_USERID + "='" + userId + "'", null);
            db.setTransactionSuccessful();
        } finally { 
            db.endTransaction();
        } 
    } 
 
    private void writeFile(String name, byte[] hash) {
        try { 
            // Write the hash to file 
            RandomAccessFile raf = new RandomAccessFile(name, "rw");
            // Truncate the file if pattern is null, to clear the lock 
            if (hash == null || hash.length == 0) {
                raf.setLength(0);
Full Snippet Info
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: close, beginTransaction, endTransaction, getVersion, setTransactionSuccessful
                    db = SQLiteDatabase.openOrCreateDatabase(new File(mPath, mName), mFactory);
                else 
                    db = mContext.openOrCreateDatabase(mName, 0, mFactory);
            } 
 
            int version = db.getVersion();
            if (version != mNewVersion) {
                db.beginTransaction();
                try { 
                    if (version == 0) {
                        onCreate(db);
                    } else { 
                        onUpgrade(db, version, mNewVersion);
                    } 
                    db.setVersion(mNewVersion);
                    db.setTransactionSuccessful();
                } finally { 
                    db.endTransaction();
                } 
            } 

8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: close, beginTransaction, compileStatement, endTransaction, isOpen
	} 
 
	public DataManager(Context context, boolean useDebugDb) {
		this.context = context;
		this.useDebugDb = useDebugDb;
	} 
 
	private boolean isOpenDb() { 
		return (db != null && db.isOpen());
	} 
 
	private boolean closeDb() { 
		if (isOpenDb()) { 
			try { 
				db.close();
				 
				db = null;
				rpgCharacterDao = null;
				 
				return true; 

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: beginTransaction, endTransaction, inTransaction
        } 
    } 
     
    @Test 
    public void testInTransaction() throws Exception { 
        assertThat(database.inTransaction()).isFalse();
    	database.beginTransaction();
        assertThat(database.inTransaction()).isTrue();
    	database.endTransaction();
        assertThat(database.inTransaction()).isFalse();
    } 
 
    protected long addChuck() { 
        return addPerson(1234L, "Chuck"); 
    } 
 
    protected long addJulie() { 
        return addPerson(1235L, "Julie"); 
    } 
 
Full Snippet Info
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: beginTransaction, endTransaction, setTransactionSuccessful
	} 
 
	/** {@inheritDoc} */ 
	@Override 
	public void onCreate(final SQLiteDatabase db) {
		db.beginTransaction();
		createTables(db);
		initTables(db);
		db.setTransactionSuccessful();
		db.endTransaction();
 
		initConfiguration(); 
	} 
 
	/** {@inheritDoc} */ 
	@Override 
	public void onOpen(final SQLiteDatabase db) {
		if (!db.isReadOnly()) {
			Log.v(TAG, "Beginning transaction for " + db.toString());
			db.beginTransaction();
Full Snippet Info
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: beginTransaction, endTransaction, execSQL, setTransactionSuccessful
        super(context, DbConstants.DB_NAME, null, DbConstants.DB_VERSION);
    } 
 
    @Override 
    public void onCreate(SQLiteDatabase db) {
        db.beginTransaction();
        try { 
            db.execSQL(DbConstants.CREATE_IMAGE_SDCARD_CACHE_TABLE_SQL.toString());
            db.execSQL(DbConstants.CREATE_IMAGE_SDCARD_CACHE_TABLE_INDEX_SQL.toString());
 
            db.execSQL(DbConstants.CREATE_HTTP_CACHE_TABLE_SQL.toString());
            db.execSQL(DbConstants.CREATE_HTTP_CACHE_TABLE_INDEX_SQL.toString());
            db.execSQL(DbConstants.CREATE_HTTP_CACHE_TABLE_UNIQUE_INDEX.toString());
            db.setTransactionSuccessful();
        } finally { 
            db.endTransaction();
        } 
    } 
 
    @Override 
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Full Snippet Info
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: beginTransaction, endTransaction, query, setTransactionSuccessful
     * @return a copy of all the MetaData fields. 
     */ 
    public Fields getFields() { 
        Fields fields = new Fields();
        SQLiteDatabase db = mOpenHelper.getReadableDatabase();
        db.beginTransaction();
        try { 
            // If the fields have not been initialized from the database, 
            // then read the database. 
            if (!mInitialized) {
                readLocked(db);
            } 
            fields.timezone = mFields.timezone;
            fields.minInstance = mFields.minInstance;
            fields.maxInstance = mFields.maxInstance;
            db.setTransactionSuccessful();
        } finally { 
            db.endTransaction();
        } 
        return fields;

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: beginTransaction, endTransaction, setTransactionSuccessful
public class DBUtils { 
 
	private static final String LOG_TAG = "DBUtils";
 
	public static <T> void executeInTransaction(final SQLiteDatabase db, final Runnable runnable) {
		db.beginTransaction();
		try { 
			runnable.run();
			db.setTransactionSuccessful();
		} 
		catch (final Exception e) {
			logError(e);
		} 
		finally { 
			db.endTransaction();
		} 
	} 
 
	@SuppressWarnings("unchecked") 
	public static <T> T executeInSafety(final Callable<?> callable) {
Full Snippet Info
6
CodeRank
Experience pair programming with AI  Get Codota for Java

Related SQLiteDatabase endTransaction Questions & Answers:

endTransaction Method Overview
End a transaction.
See Code Examples for other Android SQLiteDatabase Methods: