SQLiteOpenHelper getReadableDatabase - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for SQLiteOpenHelper getReadableDatabase method.

This code example shows how to use the following methods:getReadableDatabase, getWritableDatabase
This code example shows how to use the following methods:getReadableDatabase
     * @param helper 
     * @return readable database or null if it failed to create/open 
     */ 
    protected SQLiteDatabase getReadable(SQLiteOpenHelper helper) {
        try { 
            return helper.getReadableDatabase();
        } catch (SQLiteException e1) {
            // Make second attempt 
            try { 
                return helper.getReadableDatabase();
            } catch (SQLiteException e2) {
                return null; 
            } 
        } 
    } 
 
    /** 
     * Load or request given resources 
     * 
     * @param persistableResource 
7
CodeRank
This code example shows how to use the following methods:getReadableDatabase, getWritableDatabase
This code example shows how to use the following methods:getReadableDatabase
    database.update(TABLE_NAME, values, NUMBER + " = ? AND " + ZID + " = ?",
                    new String[] {encodedNumber, encodedZid});
  } 
 
  public boolean isVerified(String number, byte[] zid) {
    SQLiteDatabase database = databaseHelper.getReadableDatabase();
    String encodedZid       = Base64.encodeBytes(zid);
    String encodedNumber    = PhoneNumberFormatter.formatNumber(context, number);
    Cursor cursor           = null;
 
    try { 
      cursor = database.query(TABLE_NAME, new String[] {VERIFIED},
                              NUMBER + " = ? AND " + ZID + " = ?",
                              new String[] {encodedNumber, encodedZid},
                              null, null, null); 
 
      if (cursor != null && cursor.moveToFirst()) {
        return cursor.getInt(cursor.getColumnIndexOrThrow(VERIFIED)) == 1;
      } 
 
6
CodeRank
This code example shows how to use the following methods:getReadableDatabase, getWritableDatabase
	} 
 
	public MyNoteDBAdapter open() throws SQLException { 
		try { 
			Log.d(TAG, "about to getWritableDatabase");
			db = dbHelper.getWritableDatabase();
		} catch (SQLiteException ex) {
			Log.d(TAG, "about to getReadableDatabase");
			db = dbHelper.getReadableDatabase();
		} 
		return this;
	} 
 
	public void close() { 
		db.close();
	} 
 
	public MyNoteDto insertMyNote(MyNoteDto mynote) {
		// Create a new row of values to insert. 
		Log.d(TAG, "about to insertMyNote: " + mynote.getKey());
6
CodeRank
This code example shows how to use the following methods:getReadableDatabase
        final SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
        String newSelection = buildSelection(uri, selection);
        queryBuilder.setTables("tests");
        Cursor c = null;
        try { 
            db = mDatabaseHelper.getReadableDatabase();
            c = queryBuilder.query(db, projection, newSelection, selectionArgs, null, null, sortOrder);
            return c;
        } catch (RuntimeException e) {
            if (c != null) {
                c.close();
            } 
            if (db != null) {
                db.close();
            } 
            throw e;
        } 
    } 
 
    @Override 
6
CodeRank
This code example shows how to use the following methods:getReadableDatabase
This code example shows how to use the following methods:getReadableDatabase
This code example shows how to use the following methods:getReadableDatabase, getWritableDatabase
     * @throws SQLiteException if the database cannot be opened for writing 
     * @return a read/write database object valid until {@link #close} is called 
     */ 
    public synchronized SQLiteDatabase getWritableDatabase() {
    	if (mHelper != null) {
    		return mHelper.getWritableDatabase();
    	} 
        if (mDatabase != null && mDatabase.isOpen() && !mDatabase.isReadOnly()) {
            return mDatabase;  // The database is already open for business
        } 
        boolean success = false;
        SQLiteDatabase db = null;
        try { 
            db = SQLiteDatabase.openOrCreateDatabase(mName, null);
 
            int version = db.getVersion();
            if (version != mNewVersion) {
                db.beginTransaction();
                try { 
                    if (version == 0) {

6
CodeRank
This code example shows how to use the following methods:getReadableDatabase
            } 
        }; 
    } 
 
    public SQLiteDatabase getReadableDatabase() {
        return openHelper.getReadableDatabase();
    } 
 
    public SQLiteDatabase getWritableDatabase() {
        return openHelper.getWritableDatabase();
    } 
 
    public boolean addPost(Post post) {
        // Abort if post exists 
        if (exists(post.getKey())) {
            Util.debug("  Post already exists, skipping."); 
            return false; 
        } 
        final SQLiteDatabase db = openHelper.getWritableDatabase();
        ContentValues cv = new ContentValues();
6
CodeRank

Related SQLiteOpenHelper getReadableDatabase Questions & Answers:

Other SQLiteOpenHelper getReadableDatabase Examples

86:					+ " ORDER BY id DESC";
87:	
88:			SQLiteDatabase db = this.getReadableDatabase();
89:			Cursor cursor = db.rawQuery(selectQuery, null);
90:	
-
133:		 * */
134:		public WebSite getSite(int id) {
135:			SQLiteDatabase db = this.getReadableDatabase();
136:	
137:			Cursor cursor = db.query(TABLE_RSS, new String[] { KEY_ID, KEY_TITLE,

Read More

68:		// Getting single contact
69:		Contact getContact(int id) {
70:			SQLiteDatabase db = this.getReadableDatabase();
71:	
72:			Cursor cursor = db.query(TABLE_CONTACTS, new String[] { KEY_ID,
-
132:		public int getContactsCount() {
133:			String countQuery = "SELECT  * FROM " + TABLE_CONTACTS;
134:			SQLiteDatabase db = this.getReadableDatabase();
135:			Cursor cursor = db.rawQuery(countQuery, null);
136:			cursor.close();

Read More

77:			String selectQuery = "SELECT  * FROM " + TABLE_LOGIN;
78:			 
79:	        SQLiteDatabase db = this.getReadableDatabase();
80:	        Cursor cursor = db.rawQuery(selectQuery, null);
81:	        // Move to first row
-
99:		public int getRowCount() {
100:			String countQuery = "SELECT  * FROM " + TABLE_LOGIN;
101:			SQLiteDatabase db = this.getReadableDatabase();
102:			Cursor cursor = db.rawQuery(countQuery, null);
103:			int rowCount = cursor.getCount();

Read More

getReadableDatabase Method Overview
Create and/or open a database.
See Code Examples for other Android SQLiteOpenHelper Methods: