Code example for SQLiteDatabase

Methods: beginTransactionendTransactionexecSQLsetTransactionSuccessful

0
	 * android.database.sqlite.SQLiteOpenHelper#onCreate(android.database.sqlite 
	 * .SQLiteDatabase) 
	 */ 
	@Override 
	public void onCreate(SQLiteDatabase db) {
		db.beginTransaction();
		try { 
			db.execSQL("CREATE TABLE pictures (" 
					+"Id INTEGER PRIMARY KEY AUTOINCREMENT, " +  
					"Credit TEXT," + 
					"ImgurUrl TEXT," + 
					"Info TEXT," + 
					"Title TEXT," + 
					"Uid TEXT" + 
			");");  
			db.setTransactionSuccessful();
		} catch (Exception e)  {
 
		} finally { 
			db.endTransaction();
		} 
	} 
 
	/* 
	 * (non-Javadoc) 
	 *  
	 * @see 
	 * android.database.sqlite.SQLiteOpenHelper#onUpgrade(android.database.sqlite 
	 * .SQLiteDatabase, int, int) 
	 */ 
	@Override 
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.d("", "ONUPGRADE " + newVersion + " " +oldVersion);
 
		db.beginTransaction();
 
		try { 
			db.execSQL("DROP TABLE IF EXISTS apod");
			db.execSQL("DROP TABLE IF EXISTS pictures");
			db.setTransactionSuccessful();
		} catch (Exception e) {
 
		} finally { 
			db.endTransaction();
		} 
 
		onCreate(db);
	} 
 
Experience pair programming with AI  Get Codota for Java