简体   繁体   中英

Android SDK - Database Connection

How would I go about making it so when you click on a button it would take the value of EditText1 and EditText 2 than check a database to see if they match and if they do it should saying success.

This is just for testing, I just want to learn how to do this.

This is my code so far, I'm just not sure how to do the whole database part.

    final Button button1 = (Button) findViewById(R.id.Button01);
    button1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            EditText text1 = (EditText) findViewById(R.id.editText1);
            EditText text2 = (EditText) findViewById(R.id.EditText01);
        }
    });
}

Try this :

{

str1 = editText1.getText.toString();

str2 = editText2.getText.toString();

}

{

cursor c = db.query(select all ids);

while(c.moveToNext){

if(c.getId() == str1 && c.getId() == str2)

{

do sumthing

}

}

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM