Android examples for Database:SQL Query
get data from Database table by sql and table name
//package com.book2s; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; public class Main { public static String[] getData(SQLiteDatabase db, String sql, String TABLE_NAME) {/*from w ww . j a v a2 s. c om*/ Cursor cursor = db.rawQuery(sql, null); int dataNum = cursor.getCount(); String[] strData = new String[dataNum]; for (int i = 0; i < dataNum; i++) { strData[i] = cursor.getString(0); cursor.moveToNext(); } return strData; } }