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:io.vit.vitio.Managers.ConnectDatabase.java

public void clear() {
    SQLiteDatabase sqLiteDatabase = getWritableDatabase();
    String deleteQuery = "DELETE FROM " + TABLE_COURSES + ";";
    sqLiteDatabase.delete(TABLE_COURSES, "1", null);
    Cursor cursor = sqLiteDatabase.rawQuery(deleteQuery, null);
    cursor.close();//from w w  w.ja v a  2  s.  c  o m
    sqLiteDatabase.close();
}

From source file:com.futureplatforms.kirin.extensions.databases.DatabasesBackend.java

public void closeAll() {
    for (Map.Entry<String, SQLiteDatabase> entry : mDatabases.entrySet()) {
        SQLiteDatabase db = entry.getValue();
        if (db.isOpen()) {
            db.close();
        }//from  ww  w. j a  va 2s.c  om
    }

    // Should we really do this?
    mInFlightTransactions.clear();

    mDatabases.clear();

}

From source file:com.contentful.vault.SqliteHelper.java

private boolean isPendingCopy(File dbPath) {
    boolean result = false;
    if (dbPath.exists()) {
        SQLiteDatabase db = context.openOrCreateDatabase(spaceHelper.getDatabaseName(), Context.MODE_PRIVATE,
                null);/*from w ww  .ja v  a  2 s.c  o  m*/
        try {
            if (spaceHelper.getDatabaseVersion() > db.getVersion()) {
                result = true;
            }
        } finally {
            db.close();
        }
    } else {
        result = true;
    }
    return result;
}

From source file:com.dm.wallpaper.board.databases.Database.java

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

From source file:com.dm.wallpaper.board.databases.Database.java

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

From source file:com.clutch.ClutchStats.java

public int getCachedChoice(String name) {
    int resp = -1;
    SQLiteDatabase db = getReadableDatabase();
    String[] args = { name };//w w  w.j  a va  2  s  .c om
    Cursor cur = db.rawQuery("SELECT choice FROM abcache WHERE name = ?", args);
    cur.moveToFirst();
    while (!cur.isAfterLast()) {
        resp = cur.getInt(0);
        cur.moveToNext();
    }
    db.close();
    return resp;
}

From source file:edu.mit.media.funf.pipeline.BasicPipeline.java

protected void runArchive() {

    SQLiteDatabase db = databaseHelper.getWritableDatabase();
    // TODO: add check to make sure this is not empty
    File dbFile = new File(db.getPath());
    db.close();
    if (archive.add(dbFile)) {
        dbFile.delete();/*from  w ww.ja v  a2s .c  o m*/
    }
    reloadDbHelper(manager);
    db = databaseHelper.getWritableDatabase(); // Build new database
    db.close();
}

From source file:com.citrus.sdk.database.DBHandler.java

public int setDefaultOption(String optionName) {
    String whereValues[] = new String[] { optionName };
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues newValues = new ContentValues();

    if (!TextUtils.isEmpty(optionName)) {
        try {/*from w  ww  .j  ava  2 s .  co m*/
            newValues.put(DEFAULT_OPTION, 1);
            return db.update(PAYOPTION_TABLE, newValues, NAME + "=?", whereValues);
        } catch (Exception e) {
            db.close();
            return 0;
        }

    } else {
        try {
            newValues.put(DEFAULT_OPTION, 0);
            return db.update(PAYOPTION_TABLE, newValues, null, null);
        } catch (Exception e) {
            db.close();
            return 0;
        }

    }
}

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

public static HashSet<String> getBannedThreads(String group, Context context) {

    HashSet<String> bannedThreads = null;

    int groupid = getGroupIdFromName(group, context);

    DBHelper db = new DBHelper(context);
    SQLiteDatabase dbread = db.getReadableDatabase();

    String q = "SELECT clean_subject FROM banned_threads WHERE subscribed_group_id=" + groupid
            + " AND bandisabled=0";

    Cursor c = dbread.rawQuery(q, null);
    if (c.getCount() > 0) {

        bannedThreads = new HashSet<String>(c.getCount());
        c.moveToFirst();/*  www .j a  va 2  s . c om*/

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

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

    if (bannedThreads == null)
        bannedThreads = new HashSet<String>(0);
    return bannedThreads;
}

From source file:com.dm.wallpaper.board.databases.Database.java

public int getWallpapersCount() {
    SQLiteDatabase db = this.getReadableDatabase();
    Cursor cursor = db.query(TABLE_WALLPAPERS, null, null, null, null, null, null, null);
    int rowCount = cursor.getCount();
    cursor.close();//w  ww.  j a v  a2  s .c  o  m
    db.close();
    return rowCount;
}