Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.util.LinkedList;

import android.database.Cursor;

public class Main {
    public static LinkedList<Integer> retrieveIntegerFromCursor(Cursor cursor, String columnName) {
        if (null == cursor || 0 == cursor.getCount()) {
            return new LinkedList<Integer>();
        }

        LinkedList<Integer> ids = new LinkedList<Integer>();

        try {
            for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
                int id = cursor.getInt(cursor.getColumnIndexOrThrow(columnName));
                ids.add(new Integer(id));
            }
        } catch (Exception e) {
            //do nothing.
        } finally {
            cursor.close();
        }

        return ids;
    }
}