Reputation: 1455
Targeting 4.2 using Eclipse
I have a basic input screen that takes address book information from the user and puts it into a db table called myAddressBook
my code for creating the table is as follows (db is the SQLiteDatabase
declaration:
//MODE_PRIVATE = only this application
db = openOrCreateDatabase("AdddressBookDB", MODE_PRIVATE, null);
//Create the Table
db.execSQL("CREATE TABLE IF NOT EXISTS myAddressBook(Name VARCHAR, Address1 NVARCHAR, Address2 NVARCHAR, City VARCHAR, State VARCHAR, Zip INT(5), Phone INT(10));");
Now I have a Search
button on the form and an EditText
that I want to use to search my table and display the results in a list, or possibly in the original EditTexts
used for the input. In the OnClick for the Search button, I have:
String searchvalue = searchEditText.getText().toString();
To get the string of whatever the user wants to search for. Now how do I basically say "find anything in the database that partially or fully matches searchvalue
"?? (I am new to Android but VERY new to SQL)
Upvotes: 0
Views: 84
Reputation: 3261
Probably, this is answer for your question
Cursor cursor = getReadableDatabase().
rawQuery("select * from todo where _id = ?", new String[] { id });
This is good article. Please read that for getting answer for your question.
Upvotes: 2