reading the database in android
<p>Im trying to callback information from my database but encountering errors. My first class which writes to the database looks like this. (I've removed the imports and other non-essential code)</p>

<pre><code>public class AddEntry extends Activity implements OnClickListener{

private TextView mTimeDisplay;
private Button mPickTime;
private int mHour;
private int mMinute;
private EditText mmodulecode; 
private Spinner mSpinner1;
private Spinner mSpinnerDuration;
private Spinner mSpinnerClass;
private EditText mroom;

static final int TIME_DIALOG_ID = 0;

private Spinner spinner1;
private Spinner spinnerNumber;
private Spinner spinnerType;
private EventData events;

@Override
protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.addentry);
    events = new EventData(this);

    View addNewEntry = findViewById(R.id.addNewEntry);
    addNewEntry.setOnClickListener(this);


    // capture our View elements
    mTimeDisplay = (TextView) findViewById(R.id.timeDisplay);
    mPickTime = (Button) findViewById(R.id.pickTime);
    mmodulecode = (EditText) findViewById (R.id.modulecode);
    mSpinner1 = (Spinner)findViewById(R.id.spinner1);
    mSpinnerDuration = (Spinner)findViewById(R.id.spinnerNumber);
    mSpinnerClass = (Spinner)findViewById(R.id.spinnerType);
    mroom = (EditText) findViewById (R.id.room);

    // add a click listener to the button
    mPickTime.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showDialog(TIME_DIALOG_ID);
        }
    });
}

public void onClick(View v){
    switch (v.getId()){
    case R.id.addNewEntry:
        addEvent(mmodulecode.getText().toString(), mSpinner1.getSelectedItem().toString()
                , mTimeDisplay.getText().toString(), mSpinnerDuration.getSelectedItem().toString()
                , mSpinnerClass.getSelectedItem().toString(), mroom.getText().toString());
        Intent i = new Intent(this, Timetable.class);
        startActivity(i);
        break;
    }
}


private void addEvent (String modulecode, String day, String starttime, String duration, String typeofsession, String room){
    try{
    SQLiteDatabase db = events.getWritableDatabase();
    ContentValues values = new ContentValues ();
    values.put(MODULECODE, modulecode);
    values.put(DAY, day);
    values.put(STARTTIME, starttime);
    values.put(DURATION, duration);
    values.put(TYPEOFSESSION, typeofsession);
    values.put(ROOM, room);
    db.insertOrThrow(TABLE_NAME, null, values);
    }catch(SQLiteException ex){
        Toast toast = Toast.makeText(this, "Broken", 10);
        toast.show();
    }       
}
}
</code></pre>

<p>So far I'm reasonably certain this code is work fine, it is in the next class I am encountering the problem. This is the complete class.</p>

<pre><code>package org.example.timetable;

import org.example.timetable.EventData;

import android.app.Activity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import static android.provider.BaseColumns._ID;
import static org.example.timetable.Database.TABLE_NAME;
import static org.example.timetable.Database.MODULECODE;
import static org.example.timetable.Database.DAY;
import static org.example.timetable.Database.STARTTIME;
import static org.example.timetable.Database.DURATION;
import static org.example.timetable.Database.TYPEOFSESSION;
import static org.example.timetable.Database.ROOM;
import android.os.Bundle;
import android.widget.TextView;

public class ViewTimetable extends Activity{
private EventData events;
@Override
protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.viewtimetable);
    events = new EventData(this);
    try {
        Cursor cursor = getEvents();
            showEvents(cursor);
    }finally{
        events.close();
    }
}

private static String[] FROM = { _ID, MODULECODE, DAY, STARTTIME, DURATION, TYPEOFSESSION, ROOM };
private static String ORDER_BY = DAY + " DESC";
private Cursor getEvents() {
    SQLiteDatabase db = events.getReadableDatabase();
    Cursor cursor = db.query(TABLE_NAME, FROM, null, null, null, null, ORDER_BY);
    startManagingCursor(cursor);
    return cursor;
}

private void showEvents(Cursor cursor) {
    StringBuilder builder = new StringBuilder("Saved Events:\n");
    while (cursor.moveToNext()){
        long id = cursor.getLong(0);
        String modulecode = cursor.getString(1);
        String day = cursor.getString(2);
        String starttime = cursor.getString(3);
        String duration = cursor.getString(4);
        String typeofsession = cursor.getString(5);
        String room = cursor.getString(6);
        builder.append(id).append(": ");
        builder.append(modulecode).append(": ");
        builder.append(day).append(": ");
        builder.append(starttime).append(": ");
        builder.append(duration).append(": ");
        builder.append(typeofsession).append(": ");
        builder.append(room).append("\n ");
    }
    TextView text = (TextView) findViewById(R.id.text);
    text.setText(builder);
}
}
</code></pre>

<p>From what I've managed to discover it appears the problem is occuring at the line
Cursor cursor = db.query(TABLE_NAME, FROM, null, null, null, null, ORDER_BY);</p>

<p>All I want it to do is return all the data in the table.</p>

<p>Thanks</p>
