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.rener.sea.DBHelper.java

private long deleteUsers(JSONArray data) {
    SQLiteDatabase db = this.getWritableDatabase();
    int i = -1;//from  w  w w .j  a  v a  2s  .  com
    try {
        for (i = 0; i < data.length(); i++) {
            JSONObject item = data.getJSONObject(i);
            long id = db.delete(DBSchema.TABLE_USERS, DBSchema.USER_ID + "=?",
                    new String[] { String.valueOf(item.getLong(DBSchema.USER_ID)) });
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    db.close();
    return i;
}

From source file:com.rener.sea.DBHelper.java

private long deletePerson(JSONArray data) {
    SQLiteDatabase db = this.getWritableDatabase();
    int i = -1;/*  w  ww  . j  a  v  a  2  s . co  m*/
    try {
        for (i = 0; i < data.length(); i++) {
            JSONObject item = data.getJSONObject(i);
            long id = db.delete(DBSchema.TABLE_PERSON, DBSchema.PERSON_ID + "=?",
                    new String[] { String.valueOf(item.getLong(DBSchema.PERSON_ID)) });
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    db.close();
    return i;
}

From source file:com.rener.sea.DBHelper.java

private long deleteReport(JSONArray data) {
    SQLiteDatabase db = this.getWritableDatabase();
    int i = -1;/*from  w w  w. j  av a2 s  . c o m*/
    try {
        for (i = 0; i < data.length(); i++) {
            JSONObject item = data.getJSONObject(i);
            long id = db.delete(DBSchema.TABLE_REPORT, DBSchema.REPORT_ID + "=?",
                    new String[] { String.valueOf(item.getLong(DBSchema.REPORT_ID)) });
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    db.close();
    return i;
}

From source file:com.rener.sea.DBHelper.java

private long deleteAddress(JSONArray data) {
    SQLiteDatabase db = this.getWritableDatabase();
    int i = -1;/*www  .  ja v  a 2  s.  c om*/
    try {
        for (i = 0; i < data.length(); i++) {
            JSONObject item = data.getJSONObject(i);
            long id = db.delete(DBSchema.TABLE_ADDRESS, DBSchema.ADDRESS_ID + "=?",
                    new String[] { String.valueOf(item.getLong(DBSchema.ADDRESS_ID)) });
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    db.close();
    return i;
}

From source file:com.rener.sea.DBHelper.java

private long deleteCategory(JSONArray data) {
    SQLiteDatabase db = this.getWritableDatabase();
    int i = -1;/*  w  ww.ja  v a  2 s  .com*/
    try {
        for (i = 0; i < data.length(); i++) {
            JSONObject item = data.getJSONObject(i);
            long id = db.delete(DBSchema.TABLE_CATEGORY, DBSchema.CATEGORY_ID + "=?",
                    new String[] { String.valueOf(item.getLong(DBSchema.CATEGORY_ID)) });
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    db.close();
    return i;
}

From source file:com.rener.sea.DBHelper.java

private long deleteLocation(JSONArray data) {
    SQLiteDatabase db = this.getWritableDatabase();
    int i = -1;/*from ww w.  j  av a  2 s. co  m*/
    try {
        for (i = 0; i < data.length(); i++) {
            JSONObject item = data.getJSONObject(i);
            long id = db.delete(DBSchema.TABLE_LOCATION, DBSchema.LOCATION_ID + "=?",
                    new String[] { String.valueOf(item.getLong(DBSchema.LOCATION_ID)) });
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    db.close();
    return i;
}

From source file:com.rener.sea.DBHelper.java

private long deletePath(JSONArray data) {
    SQLiteDatabase db = this.getWritableDatabase();
    int i = -1;/*from  w w w  .  java  2s.  c om*/
    try {
        for (i = 0; i < data.length(); i++) {
            JSONObject item = data.getJSONObject(i);
            long id = db.delete(DBSchema.TABLE_PATH, DBSchema.PATH_REPORT_ID + "=?",
                    new String[] { String.valueOf(item.getLong(DBSchema.PATH_REPORT_ID)) });
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    db.close();
    return i;
}

From source file:com.rener.sea.DBHelper.java

private long deleteFlowchart(JSONArray data) {
    SQLiteDatabase db = this.getWritableDatabase();
    int i = -1;//from www  .j  a  v  a  2 s  .  co  m
    try {
        for (i = 0; i < data.length(); i++) {
            JSONObject item = data.getJSONObject(i);
            long id = db.delete(DBSchema.TABLE_FLOWCHART, DBSchema.FLOWCHART_ID + "=?",
                    new String[] { String.valueOf(item.getLong(DBSchema.FLOWCHART_ID)) });
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    db.close();
    return i;
}

From source file:com.rener.sea.DBHelper.java

private long deleteAppointments(JSONArray data) {
    SQLiteDatabase db = this.getWritableDatabase();
    int i = -1;/*from www. j av a  2s  .c o  m*/
    try {
        for (i = 0; i < data.length(); i++) {
            JSONObject item = data.getJSONObject(i);
            long id = db.delete(DBSchema.TABLE_APPOINTMENTS, DBSchema.APPOINTMENT_ID + "=?",
                    new String[] { String.valueOf(item.getLong(DBSchema.APPOINTMENT_ID)) });
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    db.close();
    return i;
}

From source file:com.rener.sea.DBHelper.java

public List<User> getAllUsers() {
    SQLiteDatabase db = getReadableDatabase();
    Cursor cursor = db.query(DBSchema.TABLE_USERS, new String[] { DBSchema.USER_ID }, null, null, null, null,
            null, null);/* w ww. j  av a 2  s  .  com*/
    ArrayList<User> users;
    users = new ArrayList<>();
    if ((cursor != null) && (cursor.getCount() > 0)) {

        for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
            users.add(new User(cursor.getLong(0), this));
        }

        db.close();
        cursor.close();

    }
    return users;

}