Пример #1
0
  public static Area inflate(long areaId, ContentResolver cr, int idType) {
    Area area = null;
    String whereClause;
    if (idType == IdType.LOCAL) whereClause = BetaProvider.KEY_AREA_ID + "= ?";
    else whereClause = BetaProvider.KEY_AREA_MASTER + "= ?";
    Cursor c =
        cr.query(
            Area.CONTENT_URI,
            new String[] {
              BetaProvider.KEY_AREA_ID,
              BetaProvider.KEY_AREA_NAME,
              BetaProvider.KEY_AREA_DATE_ADDED,
              BetaProvider.KEY_AREA_DATE_MODIFIED,
              BetaProvider.KEY_AREA_DETAILS,
              BetaProvider.KEY_AREA_PARENT,
              BetaProvider.KEY_AREA_LONGITUDE,
              BetaProvider.KEY_AREA_LATITUDE,
              BetaProvider.KEY_AREA_MASTER,
              BetaProvider.KEY_AREA_ID_TYPE,
              BetaProvider.KEY_AREA_STATE,
              BetaProvider.KEY_AREA_PERMISSION
            },
            whereClause,
            new String[] {String.valueOf(areaId)},
            null);
    if (c.getCount() == 1) {
      area = new Area();
      c.moveToFirst();
      area.setId(areaId);
      area.setName(c.getString(1));
      try {
        area.setDateAdded(BetaProvider.sqliteDateFormater.parse(c.getString(2)));
        area.setDateModified(BetaProvider.sqliteDateFormater.parse(c.getString(3)));
      } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      area.setDetails(c.getString(4));
      area.setParent(c.getLong(5));
      area.setLongitude(c.getString(6));
      area.setLatitude(c.getString(7));
      area.setMasterId(c.getLong(8));
      area.setIdType(c.getInt(9));
      area.setState(c.getInt(10));
      area.setPermission(c.getInt(11));
    }
    c.close();

    return area;
  }
Пример #2
0
  public static Area inflatePermission(long areaId, ContentResolver cr, int idType) {
    Area area = null;
    String whereClause;

    if (idType == IdType.LOCAL) whereClause = BetaProvider.KEY_AREA_ID + "= ?";
    else whereClause = BetaProvider.KEY_AREA_MASTER + "= ?";

    Cursor c =
        cr.query(
            Area.CONTENT_URI,
            new String[] {BetaProvider.KEY_AREA_PERMISSION},
            whereClause,
            new String[] {String.valueOf(areaId)},
            null);

    if (c.getCount() == 1) {
      area = new Area();
      c.moveToFirst();
      area.setId(areaId);
      area.setPermission(c.getInt(0));
    }
    c.close();
    return area;
  }