Code example for SQLiteDatabase

Methods: beginTransactioncompileStatementendTransactionquerysetTransactionSuccessful

0
			sql = "insert into options (option,value) values ('" + option + "',?)";
		else 
			sql = "update options set value = ? where option = '" + option + "'";
 
		SQLiteDatabase lootDB = Database.getDatabase();
		lootDB.beginTransaction();
 
		SQLiteStatement stmt = lootDB.compileStatement(sql);
		stmt.bindBlob(1, value);
		 
		try 
		{ 
			stmt.execute();
			lootDB.setTransactionSuccessful();
		} 
		catch ( SQLException e )
		{ 
			return false; 
		} 
		finally 
		{ 
			lootDB.endTransaction();
		} 
		 
		return true; 
	} 
	 
	@SuppressWarnings("unused") 
	private static Cursor cursorGetOption( String option )
	{ 
		try 
		{ 
			Database db = new Database();
		} 
		catch ( SQLException e )
		{ 
			return null; 
		} 
 
		String[] columns = {"value"};
		String[] sArgs = {option};
		Cursor cur = lootDB.query("options", columns, "option = ?", sArgs, null, null, null, "1");
		if (!cur.moveToFirst())
		{ 
			cur.close();
			return null; 
		}