dimanche 22 mars 2015

Emulator crushes and I can't fetch data

I have a created a login app that once the login is successful the user is directed to a new activity!!! I have used a bundle to store the username and pass it to a string in the new activity, Then I went to my login adapter class and created a function that gets a string and returns a database query!! But when i call the funtcion in my new activity the emulator crushes!!


Here is the code of the bundle:



String userName=editTextUserName.getText().toString();
String password=editTextPassword.getText().toString();
Bundle bundle = new Bundle();
bundle.putString("username", userName);


Here I pass what i stored in the bundle to a string:



Bundle bundle = getIntent().getExtras();
String username = bundle.getString("username");


Here is the function in the LoginDataBaseAdapter class:



public Cursor FetchRow (String username){

return db.query("LOGIN",null,"USERNAME='"+username,null,null,null,null);

}


And finally here I call the function in the new activity and pass the string declared earlier:



loginDataBaseAdapter.FetchRow(username);


Why does the emulator crushes and doesn't display the data? All it says is "Unfortunately Login_Final (name of the app) has crushed!!!


Aucun commentaire:

Enregistrer un commentaire