Code example for SQLiteDatabase

Methods: beginTransactionendTransactionexecSQLsetTransactionSuccessful

0
	{ 
		if (D) Log.d(TAG, "onCreate");
		 
		try 
		{ 
			db.beginTransaction();
			db.execSQL(CREATE_TABLE);
			db.setTransactionSuccessful();
		} 
		catch (SQLException e)
		{ 
			Log.e(TAG, e.toString());
		} 
		catch (IllegalStateException e)
		{ 
			Log.e(TAG, e.toString());
		} 
		finally 
		{ 
			db.endTransaction();
		} 
	} // end of method 
	 
	@Override 
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
	{ 
		if (D) Log.d(TAG, "onUpgrade");
		 
		// Check whether database required to update to new version 
		if (oldVersion > newVersion)
		{ 
			try 
			{ 
				db.beginTransaction();
				db.execSQL(DROP_TABLE);
				db.setTransactionSuccessful();
			} 
			catch (SQLException e)
			{ 
				Log.e(TAG, e.toString());
			} 
			catch (IllegalStateException e)
			{ 
				Log.e(TAG, e.toString());
			} 
			finally 
			{ 
				db.endTransaction();
			} 
			 
			this.onCreate(db);
		} // end of if 
	} // end of method 
Contextual code suggestions in your IDE  Get Codota for Java