Code example for SQLiteDatabase

Methods: beginTransactionendTransactioninsertsetTransactionSuccessful

0
	} 
 
	public synchronized Uri insert(final Context context,
			final SQLiteDatabase db) {
		Uri retval = null;
		db.beginTransaction();
		try { 
			beforeInsert(context, db);
 
			final long id = db.insert(getTableName(), null, getContent());
 
			if (id == -1) {
				throw new SQLException("Insert failed in " + getTableName());
			} 
			else { 
				_id = id;
				afterInsert(context, db);
				db.setTransactionSuccessful();
				retval = getUri();
			} 
		} 
		catch (SQLException e) {
			throw e;
		} 
		finally { 
			db.endTransaction();
		} 
 
		if (retval != null) {
			notifyProviderOnChange(context);
		}