I want to set the condition on the Cursor that开发者_开发知识库 if certain data not found in the database return String NOT FOUND.
static class NoteHolder {
private TextView noteText = null;
NoteHolder(View row) {
noteText = (TextView) row.findViewById(R.id.notecontent);
}
void populateFrom(Cursor c, NoteHelper helper) {
noteText.setText(helper.getAnswer(c));
}
}
MY Database Helper Code Is
public Cursor getAll() {
return (getReadableDatabase().rawQuery(
"SELECT _id,Answer From Q_A Where Answer like '%"
+ searchcontent + "%'", null));
}
public String getAnswer(Cursor c) {
return (c.getString(1));
}
Very Good Tutorial For Start Database Programming...
http://www.vogella.de/articles/AndroidSQLite/article.html
http://commonsware.com/warescription have a brilliant collection of books (they're not free, but the price is VERY good, plus you get free updates!)
http://books.google.com/books?id=5VTBuvfZDyoC&pg=PA35&source=gbs_toc_r&cad=4#v=onepage&q&f=false
This is NOT a complete book. However, there is more than enough information here for you to learn quite a bit from the ~150 pages provided. It leaves out some very basic details and it also leaves out some explanations of core concepts, but it can still be a great (free) resource. I'd recommend buying the actual book, as it has helped me tremendously due to the way it presents the information. I suck at programming so I need it presented in an easy to understand way. You can still learn a significant amount with preview available here though.
edit: For a tutorial to get you going, try: http://developer.android.com/resources/tutorials/notepad/index.html
精彩评论