/** * 获取一条图片记录 * * @param imageID * @return */ public AccessInfo getAccessInfo(String userID) { AccessInfo accessInfo = null; String selection = AccessInfoColumn.USERID + "=" + userID; Cursor cursor = newsDB.query( DBHelper.ACCESSLIB_TABLE, AccessInfoColumn.PROJECTION, selection, null, null, null, null); if (cursor != null && cursor.getCount() > 0) { cursor.moveToFirst(); accessInfo = new AccessInfo(); accessInfo.setUserID(cursor.getString(AccessInfoColumn.USERID_COLUMN)); accessInfo.setAccessToken(cursor.getString(AccessInfoColumn.ACCESS_TOKEN_COLUMN)); accessInfo.setAccessSecret(cursor.getString(AccessInfoColumn.ACCESS_SECRET_COLUMN)); } return accessInfo; }
/** * 获取全部AccessInfo信息 * * @return */ public ArrayList<AccessInfo> getAccessInfos() { ArrayList<AccessInfo> list = new ArrayList<AccessInfo>(); AccessInfo accessInfo = null; Cursor cursor = newsDB.query( DBHelper.ACCESSLIB_TABLE, AccessInfoColumn.PROJECTION, null, null, null, null, null); if (cursor.getCount() > 0) { for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { accessInfo = new AccessInfo(); accessInfo.setUserID(cursor.getString(AccessInfoColumn.USERID_COLUMN)); accessInfo.setAccessToken(cursor.getString(AccessInfoColumn.ACCESS_TOKEN_COLUMN)); accessInfo.setAccessSecret(cursor.getString(AccessInfoColumn.ACCESS_SECRET_COLUMN)); list.add(accessInfo); } } cursor.close(); cursor = null; return list; }