vendredi 6 mars 2015

My android app stop I don´t know how get a value of SQLite

I'm new programmer, I need just one value ("IdUser") of SQLite and parse to String variable, but I don't have any idea to catch it and return that value. My app stopped because of this.


Activity.java



public void onClick(View arg0) {

String LOGIN2 ="Users";
String eti = loginDataBaseAdapter.CheckEtiqueta(LOGIN2);

Toast.makeText(getApplicationContext(), eti, Toast.LENGTH_LONG).show();


}


UsersDatabaseHelper.java



public String CheckEtiqueta(String LOGIN2) {

Cursor c = db.rawQuery("SELECT * FROM "+LOGIN2+" WHERE IdUser = 20 ORDER BY IdUser LIMIT1", null);

while (c.moveToNext()) {
//Sample operation with the Database
if (c.getString(c.getColumnIndex("IdUser"))!=null) {
LOGIN2=c.getString(c.getColumnIndex("IdUser"));
return LOGIN2;
}
}
return LOGIN2;


}


Thanks


Aucun commentaire:

Enregistrer un commentaire