I dont have much knowledge in using the "Cursor" to read data of SQLite database but using some references and examples i compiled a few to setup this i dont why it would read from the database, i check if data is entered into the database using a database browser and its present can some one tell me how to make this work?
I have a separate class holding the db connections and queries, in that i have a function to get all fields which have a long value of a specifed value
public Cursor getAppointments(long date) throws SQLException
{
Cursor mCursor =
db.query(true, DATABASE_TABLE, new String[] {
KEY_ROWID,
APP_TIME,
APP_TITLE,
},
APP_DATE + "=" + date,
null,
null,
null,
null,
null);
if (mCursor != null) {
mCursor.moveToFirst();
}
return mCursor;
}
what this code is supposed to do is get all the records which have the corresponding date as the queried value and return.
Now in the main class i have this code to catch and display in a Textview, row by row.
db.open();
Display.setText("");
Cursor c = db.getAppointments(SDate);
if (c.moveToFirst())
Display.setText(DisplayTitle(c));
else
Toast.makeText(this, "No title found",
Toast.LENGTH_LONG).show();
db.close();
and the display title method is
private String DisplayTitle(Cursor c) {
String Final ="";
Final = c.getString(1) + " " +c.getString(2) + " " + c.getString(3) + "
" ;
return Final;
}
Can someone tell me what are the changes necessary inorder to retrieve the records which have the same long value as the date and display it in the textview, there can be multiple records with the same long value, so have to retrieve all the records with the same long value for date and display it in the textview.
Cheers, Looing for a fast reply. :)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…