Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.LinkedList; import android.database.Cursor; import android.util.Pair; public class Main { public static LinkedList<Pair<Integer, String>> retrieveIntegerStringPairFromCursor(Cursor cursor, String integerColumnName, String stringColumnName) { LinkedList<Pair<Integer, String>> result = new LinkedList<Pair<Integer, String>>(); if (null == cursor || 0 == cursor.getCount()) { return result; } try { for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { Integer integerVal = cursor.getInt(cursor.getColumnIndex(integerColumnName)); String stringVal = cursor.getString(cursor.getColumnIndexOrThrow(stringColumnName)); result.add(new Pair(integerVal, stringVal)); } } catch (Exception e) { //do nothing. } finally { cursor.close(); } return result; } }