Example usage for android.database.sqlite SQLiteDatabase close

List of usage examples for android.database.sqlite SQLiteDatabase close

Introduction

In this page you can find the example usage for android.database.sqlite SQLiteDatabase close.

Prototype

public void close() 

Source Link

Document

Releases a reference to the object, closing the object if the last reference was released.

Usage

From source file:com.clutch.ClutchStats.java

public void setCachedChoice(String name, int choice) {
    SQLiteDatabase db = this.getWritableDatabase();
    Object[] args = { name, choice };
    db.execSQL("INSERT INTO abcache (name, choice) VALUES (?, ?)", args);
    db.close();
}

From source file:com.cuddlesoft.nori.database.APISettingsDatabase.java

/**
 * Insert a new {@link SearchClient.Settings} into the database.
 *
 * @param settings Settings object./*from w w  w. j a  va  2  s  . c  o  m*/
 * @return ID of the newly inserted row.
 */
public long insert(SearchClient.Settings settings) {
    // Insert data into the database.
    SQLiteDatabase db = getWritableDatabase();
    final long id = db.insert(TABLE_NAME, null, searchClientSettingsToContentValues(settings));
    db.close();

    sendUpdateNotification();
    return id;
}

From source file:com.cuddlesoft.nori.database.APISettingsDatabase.java

/**
 * Delete a row from the database.//from   www  .  j a  v  a2 s .c  o  m
 *
 * @param id Row ID.
 * @return Number of rows affected.
 */
public int delete(long id) {
    // Remove row from the database.
    SQLiteDatabase db = getWritableDatabase();
    final int rows = db.delete(TABLE_NAME, COLUMN_ID + " = ?", new String[] { Long.toString(id) });
    db.close();

    sendUpdateNotification();
    return rows;
}

From source file:com.itime.team.itime.services.ITimeGcmListenerService.java

private void updateUserTable(Context context) {
    UserTableHelper dbHelper = new UserTableHelper(context, "userbase1");
    SQLiteDatabase db = dbHelper.getReadableDatabase();
    ContentValues values = new ContentValues();
    values.put("remember", false);
    db.update("itime_user", values, "id=?", new String[] { "1" });
    dbHelper.close();//  ww w  . j  ava2s.  c  o  m
    db.close();
}

From source file:com.dm.material.dashboard.candybar.databases.Database.java

public void deleteAllWalls() {
    SQLiteDatabase db = this.getWritableDatabase();
    db.delete("SQLITE_SEQUENCE", "NAME = ?", new String[] { TABLE_WALLPAPERS });
    db.delete(TABLE_WALLPAPERS, null, null);
    db.close();
}

From source file:org.thomnichols.android.gmarks.WebViewCookiesDB.java

public void deleteAllCookies() {
    SQLiteDatabase db = openDatabase(SQLiteDatabase.OPEN_READWRITE);
    if (db == null)
        return;//from w  w w. ja v a 2s.co  m
    try {
        db.delete(TABLE_NAME, null, null);
    } catch (SQLiteException ex) {
        Log.w(TAG, "Error deleting cookies", ex);
    } finally {
        db.close();
    }
}

From source file:com.almarsoft.GroundhogReader.lib.DBUtils.java

public static HashSet<String> getStarredSubjectsSet(Context context) {
    DBHelper db = new DBHelper(context);
    SQLiteDatabase dbread = db.getReadableDatabase();
    Cursor c;//from   www . j  av a  2 s.  c om

    String query = "SELECT clean_subject FROM starred_threads";
    c = dbread.rawQuery(query, null);
    HashSet<String> set = new HashSet<String>(c.getCount());

    c.moveToFirst();
    int count = c.getCount();
    for (int i = 0; i < count; i++) {
        set.add(c.getString(0));
        c.moveToNext();
    }

    c.close();
    dbread.close();
    db.close();
    return set;
}

From source file:io.vit.vitio.Managers.ConnectDatabase.java

public int getCoursesCount() {
    String countQuery = "SELECT  * FROM " + TABLE_COURSES;
    SQLiteDatabase db = this.getReadableDatabase();
    Cursor cursor = db.rawQuery(countQuery, null);

    int count = cursor.getCount();

    cursor.close();//w  w w  .  j  a  v a  2 s  .  c  o m
    db.close();

    return count;
}

From source file:com.almarsoft.GroundhogReader.lib.DBUtils.java

public static HashSet<String> getGroupSentMessagesSet(String group, Context context) {
    int groupid = getGroupIdFromName(group, context);

    HashSet<String> retVal = null;
    DBHelper db = new DBHelper(context);
    SQLiteDatabase dbread = db.getReadableDatabase();

    String q = "SELECT server_article_id FROM sent_posts_log WHERE subscribed_group_id=" + groupid;
    Cursor c = dbread.rawQuery(q, null);
    int count = c.getCount();

    retVal = new HashSet<String>(count);
    c.moveToFirst();//from ww w  .  java  2 s  .c o m

    for (int i = 0; i < count; i++) {
        retVal.add(c.getString(0));
        c.moveToNext();
    }

    c.close();
    dbread.close();
    db.close();

    return retVal;
}

From source file:com.google.android.apps.santatracker.data.DestinationDbHelper.java

public void reinitialise() {
    SQLiteDatabase db = getWritableDatabase();
    // delete all entries
    db.execSQL(SQL_DELETE_ENTRIES);// w  w w.  jav a  2s.  co m

    onCreate(db);

    db.close();
}