public static void setMasterFromLocalParentArea(Area area, ContentResolver contentResolver) { if (area.getIdType() == IdType.LOCAL) { Cursor c = contentResolver.query( Area.CONTENT_URI, new String[] {BetaProvider.KEY_AREA_MASTER}, BetaProvider.KEY_AREA_ID + " = ?", new String[] {String.valueOf(area.getParent())}, null); if (c.moveToNext()) { if (c.getLong(0) > 0) { area.setParent(c.getLong(0)); area.setIdType(IdType.MASTER); } } c.close(); } }
public static boolean updateArea(Area area, ContentResolver contentResolver) { ContentValues values = new ContentValues(); values.put(BetaProvider.KEY_AREA_NAME, area.getName()); values.put(BetaProvider.KEY_AREA_DETAILS, area.getDetails()); values.put(BetaProvider.KEY_AREA_LONGITUDE, area.getLongitude()); values.put(BetaProvider.KEY_AREA_LATITUDE, area.getLatitude()); values.put(BetaProvider.KEY_AREA_PARENT, area.getParent()); values.put(BetaProvider.KEY_AREA_STATE, area.getState()); values.put(BetaProvider.KEY_AREA_MASTER, area.getMasterId()); values.put(BetaProvider.KEY_AREA_ID_TYPE, area.getIdType()); values.put( BetaProvider.KEY_AREA_DATE_MODIFIED, BetaProvider.sqliteDateFormater.format(Calendar.getInstance().getTime())); values.put(BetaProvider.KEY_AREA_PERMISSION, area.getPermission()); String where = BetaProvider.KEY_AREA_ID + " = ?"; contentResolver.update( Area.CONTENT_URI, values, where, new String[] {String.valueOf(area.getId())}); return true; }