Hello guys, please have a look at this code and see if you could help me out. viewItem is populating from a database and the method fillRemindersData(long rowId) is only called from the reminder class. I don't know why i am getting a nullPointerException when calling the viewitems.fillRemindersData()method. if i comment the line, the code works fine and the rowId is correct. hat could be the reason? thanks
And important part of the viewItems class is:
Code:
// this is a reminder class
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view_list);
adapter = new DBAdapter(this);
viewItems = new ViewItems();
fillReminder();
}
private void fillReminder() {
Bundle extra = getIntent().getExtras();
if(extra != null){
rowId = extra.getLong(DBAdapter.KEY_ID);
message = extra.getString(NewItem.Test);
}
Toast.makeText(this, message + "its ok here" + rowId, Toast.LENGTH_LONG).show();
viewItems.fillRemindersData(rowId); // having a null pointer exception here.
}
And important part of the viewItems class is:
Code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view_list);
adapter = new DBAdapter(this);
adapter.open();
fillData();
list = (ListView)findViewById(android.R.id.list);
list.setOnItemClickListener(this);
}
protected void fillData() {
Cursor c = adapter.retrieveItems(); // method in sqlitedatabase
startManagingCursor(c);
String[] from = new String[]{DBAdapter.NAME, DBAdapter.START_DATE, DBAdapter.START_TIME};
int[] to = new int[]{R.id.viewNameId, R.id.viewDateId, R.id.viewTimeId};
customCursorAdapter items = new customCursorAdapter(this, R.layout.view_items, c, from, to);
setListAdapter(items);
}
protected void fillRemindersData(long Id) {
long row = Id;
Cursor c = adapter.retrieveRow(row); // method in sqlitedatabase
startManagingCursor(c);
String[] from = new String[]{DBAdapter.NAME, DBAdapter.START_DATE, DBAdapter.START_TIME};
int[] to = new int[]{R.id.RemindNameId, R.id.remindDateId, R.id.remindTimeId};
customCursorAdapter items = new customCursorAdapter(this, R.layout.remind_viewer, c, from, to);
setListAdapter(items);
}