My dbhelper.java have method
public Cursor report(){
SQLiteDatabase db = this.getReadableDatabase();
Cursor c = db.rawQuery("SELECT * FROM Employees", null);
return c;
}
Mainactivity.java
private List<Front1> viewReport(){
List<Front1> employeeList1 = new ArrayList<>();
Cursor c = db.report();
if (c != null && c.getCount() > 0) { // Add the addition condition
if (c.moveToFirst()) {
do{
String ids=c.getString(c.getColumnIndex("e_ids"));
String name=c.getString(c.getColumnIndex("e_name"));
Front1 front1=new Front1(ids,name1);
employeeList1.add(front1);
}while (c.moveToNext());}
}else{
Front1 front1=new Front1("101","suran");
employeeList1.add(front1);
}
I have employee table.first time application install my table has empty so application crash.if i add dumny data stop application crash but user delete dummy data again application crash.how to solve null object reference initial stage .it mean select statement used if resultset empty .i want my application run not crash.any guidence will helpfull to me.