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.dm.wallpaper.board.databases.Database.java

public void deleteWallpapers(@NonNull List<Wallpaper> wallpapers) {
    SQLiteDatabase db = this.getWritableDatabase();
    for (int i = 0; i < wallpapers.size(); i++) {
        db.delete(TABLE_WALLPAPERS, KEY_URL + " = ?", new String[] { wallpapers.get(i).getUrl() });
    }/*from w  ww . j  a  v  a  2  s.c  om*/
    db.close();
}

From source file:com.github.gfx.android.orma.example.activity.MainActivity.java

public void setupV1Database() {
    deleteDatabase(DB_NAME);//from   w ww  . j a  v  a2  s.  c  o  m
    SQLiteDatabase db = openOrCreateDatabase(DB_NAME, 0, null);
    db.setVersion(1);
    db.execSQL("CREATE TABLE todos (id INTEGER PRIMARY KEY, note TEXT NOT NULL)");
    db.execSQL("CREATE INDEX index_note_on_todos ON todos (note)");
    db.execSQL("INSERT INTO todos (note) values ('todo v1 #1'), ('todo v1 #2')");
    db.close();
}

From source file:com.rs.TCOfflineStatementCollection.java

/**
 * delete a statement from the db after it has been posted
 * @param statementPosted/*from w  ww. j a  v a  2s.co m*/
 */
public void markStatementPosted(Statement statementPosted) {
    String statementId = statementPosted.getId().toString();
    SQLiteDatabase database;
    TCLocalStorageDatabaseOpenHelper dbHelper;
    dbHelper = new TCLocalStorageDatabaseOpenHelper(appContext);
    database = dbHelper.getWritableDatabase();

    String select = LocalStatements.STATEMENT_ID + "=" + "\'" + statementId + "\'";

    int count = database.delete(TCOfflineDataManager.LOCAL_STATEMENT_TABLE_NAME, select, null);

    database.close();
    dbHelper.close();
}

From source file:com.seneca.android.senfitbeta.DbHelper.java

public boolean getUser(String email, String pass) {
    String selectQuery = "select * from " + USER_TABLE + " where " + COLUMN_EMAIL + " = " + "'" + email + "'"
            + " and " + COLUMN_PASS + " = " + "'" + pass + "'";

    SQLiteDatabase db = this.getReadableDatabase();
    Cursor cursor = db.rawQuery(selectQuery, null);
    cursor.moveToFirst();//w  w w . j a v  a  2  s  .  c o m

    if (cursor.getCount() > 0) {
        return true;
    }
    cursor.close();
    db.close();
    return false;
}

From source file:com.seneca.android.senfitbeta.DbHelper.java

public void addUsers(String email, String password) {
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put(COLUMN_EMAIL, email);//from   ww  w .jav  a  2  s.  c  o  m
    values.put(COLUMN_PASS, password);

    long id = db.insert(USER_TABLE, null, values);
    db.close();
}

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

public void selectCategory(int id, boolean isSelected) {
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues values = new ContentValues();
    values.put(KEY_SELECTED, isSelected ? 1 : 0);
    db.update(TABLE_CATEGORIES, values, KEY_ID + " = ?", new String[] { String.valueOf(id) });
    db.close();
}

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

public void favoriteWallpaper(int id, boolean isFavorite) {
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues values = new ContentValues();
    values.put(KEY_FAVORITE, isFavorite ? 1 : 0);
    db.update(TABLE_WALLPAPERS, values, KEY_ID + " = ?", new String[] { String.valueOf(id) });
    db.close();
}

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

public void selectCategoryForMuzei(int id, boolean isSelected) {
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues values = new ContentValues();
    values.put(KEY_MUZEI_SELECTED, isSelected ? 1 : 0);
    db.update(TABLE_CATEGORIES, values, KEY_ID + " = ?", new String[] { String.valueOf(id) });
    db.close();
}

From source file:com.cryart.sabbathschool.util.SSCore.java

public void ssSaveComments(int ssDaySerial, String comments) {
    SQLiteDatabase db = this.getWritableDatabase();
    Cursor cu = db.rawQuery("UPDATE ss_days SET day_comments = ? " + "WHERE serial = ?",
            new String[] { comments, String.valueOf(ssDaySerial) });
    cu.moveToFirst();/*from  w  w w .  ja  v a 2 s  .  c o m*/
    cu.close();
    db.close();
}

From source file:com.cryart.sabbathschool.util.SSCore.java

public void ssSaveHighlights(int ssDaySerial, String highlights) {
    SQLiteDatabase db = this.getWritableDatabase();
    Cursor cu = db.rawQuery("UPDATE ss_days SET day_highlights = ? " + "WHERE serial = ?",
            new String[] { highlights, String.valueOf(ssDaySerial) });
    cu.moveToFirst();//from  w  w w.j  av  a 2  s . c o  m
    cu.close();
    db.close();
}