get Float List by database Query - Android Database

Android examples for Database:Cursor Get

Description

get Float List by database Query

Demo Code


//package com.java2s;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import java.util.ArrayList;

public class Main {
    public static ArrayList<Float> getFloatListbyDBQuery(SQLiteDatabase db,
            String sql, String fieldName) {
        Cursor cursor = db.rawQuery(sql, null);
        int index = cursor.getColumnIndex(fieldName);
        ArrayList<Float> retList = new ArrayList<Float>();

        cursor.moveToFirst();//from   ww w  .  j  a v  a2  s.  c om

        while (!cursor.isAfterLast()) {
            retList.add(cursor.getFloat(index));
            cursor.moveToNext();
        }

        return retList;
    }
}

Related Tutorials