Here you can find the source of selectFromTable(SQLiteDatabase db, String table, String sample)
public static ArrayList<String> selectFromTable(SQLiteDatabase db, String table, String sample)
//package com.java2s; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import java.util.ArrayList; public class Main { public final static String NESTLE_PRIMARY_KEY = "_id"; public final static String NESTLE_COLUMN_1 = "date"; public final static String NESTLE_COLUMN_2 = "first"; public final static String NESTLE_COLUMN_3 = "last"; public final static String NESTLE_COLUMN_4 = "difference"; public static ArrayList<String> selectFromTable(SQLiteDatabase db, String table, String sample) { ArrayList<String> list = new ArrayList<String>(); Cursor cursor = db.query(table, new String[] { NESTLE_COLUMN_1, NESTLE_COLUMN_2, NESTLE_COLUMN_3, NESTLE_COLUMN_4 }, NESTLE_PRIMARY_KEY + " LIKE ?", new String[] { sample }, null, null, null);/*w w w . j av a2 s . com*/ while (cursor.moveToNext()) { String s = null; StringBuffer buffer = new StringBuffer(); for (String col : new String[] { NESTLE_COLUMN_2, NESTLE_COLUMN_3, NESTLE_COLUMN_4 }) { s = cursor.getString(cursor.getColumnIndex(col)); if (s != null && s.length() > 0) buffer.append(s + ":"); else buffer.append("null:"); } list.add(buffer.toString()); } return list; } }