Code example for SQLiteOpenHelper

Methods: closegetWritableDatabase

0
		db.close();
		return qrcodes;
	} 
	 
	public synchronized void insertQRCode(QRCode qrcode) {
		SQLiteDatabase db = mQRCodeDBHelper.getWritableDatabase();
		 
		ContentValues qrcodeValues = new ContentValues();
		qrcodeValues.put(URL, qrcode.getId());
		ByteArrayOutputStream ostream = new ByteArrayOutputStream();
		qrcode.getBitmap().compress(Bitmap.CompressFormat.JPEG, 100, ostream);
		qrcodeValues.put(IMAGE, ostream.toByteArray());
		qrcodeValues.put(DATE, qrcode.getDate().getTime());
		db.insert(QRCODES_TABLE, URL, qrcodeValues);
		 
		mQRCodeDBHelper.close();
	} 
	 
	public synchronized void removeOldestQRCode() { 
		SQLiteDatabase db = mQRCodeDBHelper.getWritableDatabase();
		Cursor cursor = db.query(QRCODES_TABLE, null, null, null, null, null, DATE + " ASC", "1");
Stop searching for code, let great code find you!  Add Codota to your java IDE