Code example for SQLiteStatement

Methods: closebindStringexecutetoString

0
SQLiteDatabase db = getWritableDatabase();
		SettingsContainer settingsRef = SettingsContainer.getSettingsContainer();
		 
		SQLiteStatement sqlStatement = db.compileStatement("UPDATE settings SET settingValue = ? WHERE settingName = ?");
		sqlStatement.bindString(1, value);
		sqlStatement.bindString(2, setting);
		 
		boolean success = false;
		db.beginTransaction();
		try 
		{ 
			Log.d("JoeTest", "SqlStatement is " + sqlStatement.toString());
			sqlStatement.execute();
			db.setTransactionSuccessful();
			settingsRef.setPersistentSetting(setting, value);
			success = true;
		} 
		catch (SQLException ex)
		{ 
			ex.printStackTrace();
		} 
		finally 
		{ 
			db.endTransaction();
			sqlStatement.close();
			db.close();
		} 
		 
		return success;
	} 
Stop searching for code, let great code find you!  Add Codota to your java IDE