Here is my fetch IDs function in DBAdapter class:
I want to fetch all the IDs and display the list in a toast message, cant understand where I am going wrong.
public Cursor fetchAllIDs() {
return mDb.query(DATABASE_TABLE0, new String[] {IDno1}, null, null, null, null, null);
}
Here is my function which I call on a button click and I want my toast to be filled with all IDs.
private void fillData() {
// Get all of the IDs from the database
Cursor c = DBHelper.fetchAllIDs();
startManagingCursor(c);
String[] from = new String[] {DBAdapter.IDno1 };
Toast.makeText(getApplicationContext(), ""+from, Toast.LENGTH_LONG).show();
}
First, you are returning a
Cursorbut then you never use the information in thisCursor.Second, you cannot display a
String[]as a string anyway. You’d have to loop through theString[]and display the values one by one.You want something like this:
Edit: Fixed
getLong()togetString().