0

I'm using this method to display a table and its content from SQLite on a ListView:

listView.setAdapter(new MySimpleCursorAdapter(this, R.layout.listitems,
                managedQuery(Uri.withAppendedPath(Provider.CONTENT_URI,
                        Database.Project.NAME), new String[] { BaseColumns._ID,
                        Database.Project.C_PROJECTTITLE,
                        Database.Project.C_SMALLIMAGE, Database.Project.C_PROJECTDESCRIPTION, Database.Project.C_ORGANIZATIONTITLE, Database.Project.C_DONATIONAMOUNT, Database.Project.C_KEYWORD, Database.Project.C_PRICE, Database.Project.C_SHORTCODE}, null, null, null),
                new String[] { Database.Project.C_PROJECTTITLE,
                        Database.Project.C_SMALLIMAGE, Database.Project.C_PROJECTDESCRIPTION, Database.Project.C_ORGANIZATIONTITLE, Database.Project.C_DONATIONAMOUNT}, new int[] {
                        R.id.txt_title, R.id.image, R.id.txt_list_desc, R.id.txt_org, R.id.btn_amount}));

Now I'm wondering how am I able to do this:

For example I want to display only Database.Project.C_PROJECTTITLE which contains the word 'Health' in its column.

So only the PROJECTS whose PROJECTTITLE contain the word 'Health' will show up on the list.

It doesn't have to be EQUAL 'Health', so the PROJECTTITLE with the name for example 'Health/Bio' also appears on the list. How am I able to perform that?

2 Answers 2

1

You query should be something like below:

db.query(TABLE_NAME, new String[] {"_id", "yourColumn"},"yourColumn like " + "'%Health%'", null, null, null, null);

Sign up to request clarification or add additional context in comments.

1 Comment

Database.Project.C_SHORTCODE}, null, null, null, replace first null wtih "yourColumn like " + "'%Health%'". YourColumn should be your project titile coulmn.
0

If you let the search term be %health% then it should select all rows that contain health.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.