0

First sorry for my poor english :)

I click button but app close automaticly

I want if user exist database , read editttext "exist"

Database activity code:

public Boolean varmi(String KULLANICI) {
    // TODO Auto-generated method stub

    Cursor c = DB_Database.query(DATABASE_TABLOSU, kolonlar, K_ADI + "=" + KULLANICI, null, null, null, null);

    if(c.moveToFirst()){
        return true;
    }
    else{
        return null;
    }
}

Main activity code:

buttonGiris.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            String KULLANICI=editKullanici.getText().toString();
            db.dbyiac();
            if(db.varmi(KULLANICI) != null){
                textBilgiler.setText("User exist");
            }
            else{textBilgiler.setText("User don't exist");}
            db.dbyikapat();


        }
1

2 Answers 2

1

String literals in SQL must be in single quotes. Better yet, use ? literal placeholder and argument binding:

Cursor c = DB_Database.query(DATABASE_TABLOSU, kolonlar, K_ADI + "=?", new String[] { KULLANICI }, null, null, null);
Sign up to request clarification or add additional context in comments.

Comments

0

cursor.getColumnIndex(String columnName) returns -1 if, the column doesn't exist :) and call this method textBilgiler.setText("User don't exist"); :) kolay gele.

1 Comment

Dostum yukarıdakinin söylediği işe yaradı teşekkürler keşke türkçe yazaydın sende :D

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.