SQLiteDatabase setTransactionSuccessful - 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 setTransactionSuccessful 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; 
9
CodeRank
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;
7
CodeRank
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);
7
CodeRank
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
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();
7
CodeRank
This code example shows how to use the following methods:beginTransaction, compileStatement, endTransaction, isOpen, setTransactionSuccessful
		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; 
			} catch (SQLiteException e) {
				// Log.w("DataManager", e.getMessage()); 
			} 

7
CodeRank
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
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) {
7
CodeRank
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) {
6
CodeRank
This code example shows how to use the following methods:beginTransaction, endTransaction, execSQL, isReadOnly, setTransactionSuccessful
 
	@Override 
	public void onOpen(SQLiteDatabase db) {
		super.onOpen(db);
		 
		if(!db.isReadOnly()){
 
			// create table 
	        db.execSQL("create table if not exists bookmark("
        		+"_id integer primary key AUTOINCREMENT" 
        		+",uri text" 
        		+",lno int" 
        		+",fname text" 
        		+",caption text" 
        		+",ctime int" 
	        +")"); 
	         
			// create table 
	        db.execSQL("create table if not exists tmpdir("
        		+"_id integer primary key AUTOINCREMENT" 

6
CodeRank

Related SQLiteDatabase setTransactionSuccessful Questions & Answers:

setTransactionSuccessful Method Overview
Marks the current transaction as successful.
See Code Examples for other Android SQLiteDatabase Methods: