List of usage examples for android.database.sqlite SQLiteDatabase close
public void close()
From source file:com.rener.sea.DBHelper.java
private long deleteSpecialization(JSONArray data) { SQLiteDatabase db = this.getWritableDatabase(); int i = -1;/*from w w w . j a v a2s . com*/ try { for (i = 0; i < data.length(); i++) { JSONObject item = data.getJSONObject(i); long id = db.delete(DBSchema.TABLE_SPECIALIZATION, DBSchema.SPECIALIZATION_ID + "=?", new String[] { String.valueOf(item.getLong(DBSchema.SPECIALIZATION_ID)) }); } } catch (JSONException e) { e.printStackTrace(); } db.close(); return i; }
From source file:com.rener.sea.DBHelper.java
public User findUserByUsername(String username) { SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.query(DBSchema.TABLE_USERS, new String[] { DBSchema.USER_ID, DBSchema.USER_USERNAME, DBSchema.USER_PASSHASH, DBSchema.USER_PERSON_ID, DBSchema.USER_SALT }, DBSchema.USER_USERNAME + "=?", new String[] { String.valueOf(username) }, null, null, null, null); if ((cursor != null) && (cursor.getCount() > 0)) { cursor.moveToFirst();//ww w . j a v a2 s .com User user = new User(cursor.getLong(0), this); db.close(); cursor.close(); return user; } return new User(-1, this); }
From source file:com.rener.sea.DBHelper.java
private long setSyncItem(JSONArray data) { SQLiteDatabase db = this.getWritableDatabase(); int i = -1;/* w w w . j ava2 s . c o m*/ try { for (i = 0; i < data.length(); i++) { JSONObject item = data.getJSONObject(i); ContentValues values = new ContentValues(); values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO); db.update(DBSchema.TABLE_ITEM, values, DBSchema.ITEM_ID + " =? ", new String[] { String.valueOf(item.getLong(DBSchema.ITEM_ID)) }); } } catch (JSONException e) { e.printStackTrace(); } db.close(); return i; }
From source file:com.rener.sea.DBHelper.java
private long setSyncUsers(JSONArray data) { SQLiteDatabase db = this.getWritableDatabase(); int i = -1;// ww w . j a v a2s . com try { for (i = 0; i < data.length(); i++) { JSONObject item = data.getJSONObject(i); ContentValues values = new ContentValues(); values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO); db.update(DBSchema.TABLE_USERS, values, 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 setSyncOption(JSONArray data) { SQLiteDatabase db = this.getWritableDatabase(); int i = -1;/* w w w. j a v a 2s.c o m*/ try { for (i = 0; i < data.length(); i++) { JSONObject item = data.getJSONObject(i); ContentValues values = new ContentValues(); values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO); db.update(DBSchema.TABLE_OPTION, values, DBSchema.OPTION_ID + " =? ", new String[] { String.valueOf(item.getLong(DBSchema.OPTION_ID)) }); } } catch (JSONException e) { e.printStackTrace(); } db.close(); return i; }
From source file:com.rener.sea.DBHelper.java
private long setSyncPerson(JSONArray data) { SQLiteDatabase db = this.getWritableDatabase(); int i = -1;/*from w w w . ja v a 2 s.c o m*/ try { for (i = 0; i < data.length(); i++) { JSONObject item = data.getJSONObject(i); ContentValues values = new ContentValues(); values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO); db.update(DBSchema.TABLE_PERSON, values, 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 setSyncReport(JSONArray data) { SQLiteDatabase db = this.getWritableDatabase(); int i = -1;/* w w w . java2 s. c o m*/ try { for (i = 0; i < data.length(); i++) { JSONObject item = data.getJSONObject(i); ContentValues values = new ContentValues(); values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO); db.update(DBSchema.TABLE_REPORT, values, 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 setSyncDevices(JSONArray data) { SQLiteDatabase db = this.getWritableDatabase(); int i = -1;/*from w ww . j av a 2s . c om*/ try { for (i = 0; i < data.length(); i++) { JSONObject item = data.getJSONObject(i); ContentValues values = new ContentValues(); values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO); db.update(DBSchema.TABLE_DEVICES, values, DBSchema.DEVICE_ID + " =? ", new String[] { String.valueOf(item.getLong(DBSchema.DEVICE_ID)) }); } } catch (JSONException e) { e.printStackTrace(); } db.close(); return i; }
From source file:com.rener.sea.DBHelper.java
private long setSyncAddress(JSONArray data) { SQLiteDatabase db = this.getWritableDatabase(); int i = -1;//from w w w .ja va 2s . c om try { for (i = 0; i < data.length(); i++) { JSONObject item = data.getJSONObject(i); ContentValues values = new ContentValues(); values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO); db.update(DBSchema.TABLE_ADDRESS, values, 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 setSyncCategory(JSONArray data) { SQLiteDatabase db = this.getWritableDatabase(); int i = -1;/* w w w . ja v a 2s .c o m*/ try { for (i = 0; i < data.length(); i++) { JSONObject item = data.getJSONObject(i); ContentValues values = new ContentValues(); values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO); db.update(DBSchema.TABLE_CATEGORY, values, DBSchema.CATEGORY_ID + " =? ", new String[] { String.valueOf(item.getLong(DBSchema.CATEGORY_ID)) }); } } catch (JSONException e) { e.printStackTrace(); } db.close(); return i; }