Exemplo n.º 1
0
  public static UserData getData(Context context, String server) {
    String selection = DatabaseContract.MemberInfoTable.KEY_MEM_SERVER + "=?";
    String selectionArg[] = {server};
    Cursor cursor =
        context
            .getContentResolver()
            .query(
                DatabaseContract.MemberInfoTable.CONTENT_URI, null, selection, selectionArg, null);
    UserData userData = null;
    if (cursor != null && cursor.moveToFirst()) {
      userData = new UserData();
      userData.id =
          cursor.getString(cursor.getColumnIndex(DatabaseContract.MemberInfoTable.KEY_MEM_ID));
      userData.pwd =
          cursor.getString(cursor.getColumnIndex(DatabaseContract.MemberInfoTable.KEY_MEM_PWD));
      userData.name =
          cursor.getString(cursor.getColumnIndex(DatabaseContract.MemberInfoTable.KEY_MEM_NAME));
      userData.email =
          cursor.getString(cursor.getColumnIndex(DatabaseContract.MemberInfoTable.KEY_MEM_EMAIL));
      userData.homepage =
          cursor.getString(
              cursor.getColumnIndex(DatabaseContract.MemberInfoTable.KEY_MEM_HOMEPAGE));
      userData.level =
          cursor.getInt(cursor.getColumnIndex(DatabaseContract.MemberInfoTable.KEY_MEM_LEVEL));
      userData.point =
          cursor.getString(cursor.getColumnIndex(DatabaseContract.MemberInfoTable.KEY_MEM_POINT));
      userData.comment =
          cursor.getString(cursor.getColumnIndex(DatabaseContract.MemberInfoTable.KEY_MEM_COMMENT));
      userData.discloseInfo =
          (cursor.getInt(
                  cursor.getColumnIndex(DatabaseContract.MemberInfoTable.KEY_MEM_DISCLOSE_INFO))
              == 1);
      userData.isShowComment =
          (cursor.getInt(
                  cursor.getColumnIndex(DatabaseContract.MemberInfoTable.KEY_MEM_IS_SHOW_COMMENT))
              == 1);
      userData.server =
          cursor.getString(cursor.getColumnIndex(DatabaseContract.MemberInfoTable.KEY_MEM_SERVER));
    }

    return userData;
  }
Exemplo n.º 2
0
 public static ArrayList<UserData> getAllData(Context context) {
   Cursor cursor =
       context
           .getContentResolver()
           .query(DatabaseContract.MemberInfoTable.CONTENT_URI, null, null, null, null);
   ArrayList<UserData> userDatas = new ArrayList<UserData>();
   while (cursor != null && cursor.moveToNext()) {
     UserData userData = new UserData();
     userData.id =
         cursor.getString(cursor.getColumnIndex(DatabaseContract.MemberInfoTable.KEY_MEM_ID));
     userData.pwd =
         cursor.getString(cursor.getColumnIndex(DatabaseContract.MemberInfoTable.KEY_MEM_PWD));
     userData.name =
         cursor.getString(cursor.getColumnIndex(DatabaseContract.MemberInfoTable.KEY_MEM_NAME));
     userData.email =
         cursor.getString(cursor.getColumnIndex(DatabaseContract.MemberInfoTable.KEY_MEM_EMAIL));
     userData.homepage =
         cursor.getString(
             cursor.getColumnIndex(DatabaseContract.MemberInfoTable.KEY_MEM_HOMEPAGE));
     userData.level =
         cursor.getInt(cursor.getColumnIndex(DatabaseContract.MemberInfoTable.KEY_MEM_LEVEL));
     userData.point =
         cursor.getString(cursor.getColumnIndex(DatabaseContract.MemberInfoTable.KEY_MEM_POINT));
     userData.comment =
         cursor.getString(cursor.getColumnIndex(DatabaseContract.MemberInfoTable.KEY_MEM_COMMENT));
     userData.discloseInfo =
         (cursor.getInt(
                 cursor.getColumnIndex(DatabaseContract.MemberInfoTable.KEY_MEM_DISCLOSE_INFO))
             == 1);
     userData.isShowComment =
         (cursor.getInt(
                 cursor.getColumnIndex(DatabaseContract.MemberInfoTable.KEY_MEM_IS_SHOW_COMMENT))
             == 1);
     userData.server =
         cursor.getString(cursor.getColumnIndex(DatabaseContract.MemberInfoTable.KEY_MEM_SERVER));
     userDatas.add(userData);
   }
   return userDatas;
 }