I'm trying to use the following code to show one intent if the record count is = too or greater then 5 and a different intent if the record count is less then 5 on the first button of a dashboard layout.
But I keep getting the evil NullPointError..........Am I on the right track or am I flapping in the wind, please help and point out what i'm doing wrong...Thanks
private class DashboardClickListener implements OnClickListener {
// @Override
public void onClick(View v) {
Intent i = null;
switch (v.getId()) {
case R.id.dashboard_button_one:
if (mDbHelper.fetchAllNotes().getCount() >= 5){
i = new Intent(DashboardActivity.this, Demo.class);}
else if (mDbHelper.fetchAllNotes().getCount() < 5){
i = new Intent(DashboardActivity.this, one.class);}
break;
case R.id.dashboard_button_two:
i = new Intent(DashboardActivity.this, two.class);
break;
case R.id.dashboard_button_three:
i = new Intent(DashboardActivity.this, three.class);
break;
case R.id.dashboard_button_four:
i = new Intent(DashboardActivity.this, four.class);
break;
default:
break;
}
if(i != null) {
startActivity(i);
}
}
}