Code example for SQLiteDatabase

Methods: beginTransactionendTransactionexecSQLsetTransactionSuccessful

0
	public void tearDown() throws Exception { 
		dbCleanup("DELETE FROM REVIEWS;"); 
		 
		try { 
			//to compress the unused space and clean pages left after cleaning tables 
			db.execSQL("VACUUM;");
		} catch(SQLException sqle) {
			fail();
			sqle.printStackTrace();
		} finally { 
			testDBInstance.close();
		} 
		 
		getActivity().finish(); 
		super.tearDown(); 
	} 
	 
	//Since android doesn't provide db transaction methods, we'll clean up db ourselves 
	//This is dependent on real code which it shouldn't be but for now I think it's ok. 
	private void dbCleanup(final String sqlStatement) {
		db.beginTransaction();
		try { 
			db.execSQL(sqlStatement);
			db.setTransactionSuccessful();
		} catch(SQLException sqle) {
			sqle.printStackTrace();
			fail();
		}finally { 
			db.endTransaction();
		} 
	} 
} 
Connect your IDE to all the code out there  Get Codota for Java