How To Display Specific Data From A Sqlite Database In A Listview With A Condition Like 'where'?
I made an application with an SQLite database. I want to show the data in a listview, but I don't want to show all the data from the database, but just some data. So, I want to add
Solution 1:
I don't know about android but for sql
try this
select data_to_print from table_name whereREGEXP_LIKE(column_name_where_to_match,'dag$');
more info here http://docs.oracle.com/cd/B12037_01/server.101/b10759/ap_posix001.htm#i690819
Example:
SQL>select job_id from jobs where regexp_like(job_id,'N$');
JOB_ID
----------
MK_MAN
PU_MAN
SA_MAN
ST_MAN
Solution 2:
you need a new method in your DataManipulator
class:
publicList<String[]> selectSome(String arg) {
String[] columns = newString[] { "id", "dag", "uur", "vak", "lokaal" };
String[] selectionArgs = {arg};
Cursor cursor = db.query(TABLE_NAME, columns, "dag = ?", selectionArgs, null, null, "dag asc");
List<String[]> list = newArrayList<String[]>(cursor.getCount());
while (cursor.moveToNext()) {
String[] b1 = newString[] { cursor.getString(0),
cursor.getString(1), cursor.getString(2),
cursor.getString(3), cursor.getString(4) };
list.add(b1);
}
cursor.close();
return list;
}
I'll say it again. consider using a CursorAdapter
for these tasks.
Post a Comment for "How To Display Specific Data From A Sqlite Database In A Listview With A Condition Like 'where'?"