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<String> retrieveStringFromCursor(Cursor cursor, String columnName) {
        LinkedList<String> result = new LinkedList<String>();

        if (null == cursor || 0 == cursor.getCount()) {
            return result;
        }

        try {
            for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
                String str = cursor.getString(cursor.getColumnIndexOrThrow(columnName));
                result.add(str);
            }
        } catch (Exception e) {
            //do nothing.
        } finally {
            cursor.close();
        }

        return result;
    }
}