I have database called wisherDB, and I have a table called tbltasks inside the database.
The Table simply has colmmn names of id, title, name, date, time, and type. I want to get id, name, and the time to relate to the current date, and I can access current date by a Calendar class, so that is not the problem.
The selection code is in a seperate class called DataAccess and code is mentioned below.
What I want to do is get the details from the query and display it on the tableview. I tried this without selection of date[where clause][that means select * from …] that is working for this.
But with the selection, it’s not showing the data.
DatabaseAccess class Select query:
public Cursor getTasktoDate(String Date) throws SQLException
{
Cursor mCursor=db.query(true, DATABASE_TABLE, new String[] {KEY_ROWID,KEY_TASKNAME,KEY_TASKTYPE}, KEY_TASKDATE+"="+ Date, null, null, null, null, null);
if(mCursor!=null)
{
mCursor.moveToFirst();
}
return mCursor;
}
And this is the code of the activity:
Cursor c=dba.getTasktoDate("2011/10/12");
if (c.moveToFirst())
{
do {
DisplayContact(c, tltodaytask);
} while (c.moveToNext());
}
dba.Close();
}
private void DisplayContact(Cursor c, TableLayout tltodaytask) {
// TODO Auto-generated method stub
String id=c.getString(0);
String tName=c.getString(1);
String tType=c.getString(2);
insertRow(tltodaytask,id,tName,tType);
}
private void insertRow(TableLayout tltodaytask, String id, String tName,
String tType) {
// TODO Auto-generated method stub
final TableRow newrow = new TableRow(this);
addTexttoRowswithValues(newrow, id);
addTexttoRowswithValues(newrow, tName);
addTexttoRowswithValues(newrow, tType);
tltodaytask.addView(newrow);
}
private void addTexttoRowswithValues(TableRow newrow, String text) {
// TODO Auto-generated method stub
TextView textview = new TextView(this);
textview.setWidth(115);
textview.setText(text);
newrow.addView(textview);
}
This method not working.
You have problem in
You should use