I am learning programming and trying developing very basic Dictionary Application using Android Studio.
Database and table created, when application runs and able to populate data using following query. Cursor res = db.rawQuery("select * from " + TABLE_NAME + " WHERE WORD = 'home' ", null);
The problems is that, in MainActivity class, I have created a method
public EditText getEditText(){
EditText getText = (EditText)findViewById(R.id.editText_SearchWords);
return getText;
}
and in DatabaseHelper Class.
public Cursor getWord() {
MainActivity obj = new MainActivity();
EditText searchWord = obj.getEditText();
String word = searchWord.getText().toString();
SQLiteDatabase db = this.getWritableDatabase();
Cursor res = db.rawQuery("select * from " + TABLE_NAME + " WHERE WORD ="+word, null);
return res;
}
However, after implementing above query and method, App crashes and does not do anything. It have been playing up for a week and couldn't figure out the problems. Any help would be great support in my learning.
Aucun commentaire:
Enregistrer un commentaire