Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue From Reading from a SQLite Database
    text
    copied!<p>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?</p> <p>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</p> <pre><code>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; } </code></pre> <p>what this code is supposed to do is get all the records which have the corresponding date as the queried value and return.</p> <p>Now in the main class i have this code to catch and display in a Textview, row by row.</p> <pre><code> 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(); </code></pre> <p>and the display title method is </p> <pre><code>private String DisplayTitle(Cursor c) { String Final =""; Final = c.getString(1) + " " +c.getString(2) + " " + c.getString(3) + "\n" ; return Final; } </code></pre> <p>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. </p> <p>Cheers, Looing for a fast reply. :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload