Android examples for Database:Cursor Get
get String List by database Query
//package com.java2s; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import java.util.ArrayList; public class Main { public static ArrayList<String> getStringListbyDBQuery( SQLiteDatabase db, String sql, String fieldName) { Cursor cursor = db.rawQuery(sql, null); int index = cursor.getColumnIndex(fieldName); ArrayList<String> retList = new ArrayList<String>(); cursor.moveToFirst();//from w ww.j a v a2 s. com while (!cursor.isAfterLast()) { retList.add(cursor.getString(index)); cursor.moveToNext(); } return retList; } }