You are getting null object exception because you have not initialise SQLiteDatabase
before do operation
Just need to replace your method
public void executeEventInsert(String name, String score){
//For write data to your database
SQLiteDatabase db = this.getWritableDatabase();
String query="INSERT INTO universityFinder(univName, score) VALUES('"+name+"','"+score+"');";
db.execSQL(query);
}
and
public ArrayList<HashMap<String,String>> executeSelectEvents(int input){
String query="select * from "+TABLE_NAME+ " where " +COLUMN_SCORE+" >="+input;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor= db.rawQuery(query,null);
ArrayList<HashMap<String,String>> events=new ArrayList<>();
while (cursor.moveToNext()){
HashMap<String,String> event=new HashMap<>();
String colUniversityId=cursor.getColumnName(0);
String colUniversityIdValue=cursor.getString(0);
String colUniversityName=cursor.getColumnName(1);
String colUniversityValue=cursor.getString(1);
event.put(colUniversityId,colUniversityIdValue);
event.put(colUniversityName,colUniversityValue);
events.add(event);
}
return events;
}
Happy coding 🙂
0
solved Missing Syntax for displaying data in listview [duplicate]