SQLITE database에 회원가입한 자료들을 넣고 로그인을 구현했는데 처음에 숫자로만 받았다가 성공을 해서 문자도 받아서 하려고 하는데 xml코드에서 inputType을 number에서 text로 바꾸고 했는데
로그인이 안돼서 확인해보니까 문자열이 섞인 아이디가 db에 들어가질 않습니다 ㅜㅜ
database.execSQL("CREATE TABLE if not exists " + tableName + "(" +
"_id integer PRIMARY KEY autoincrement," +
"name text," +
"pass text," +
"passCheck text," +
"num text," +
"major text" +
")");
public void login(View v) {
if (database != null) {
Cursor cursor = database.rawQuery("SELECT name, num, pass FROM " + tableName, null);
int count = cursor.getCount();
for(int i=0;i<count;i++) {
cursor.moveToNext();
Cname = cursor.getString(0);
Cnum = cursor.getString(1);
Cpass = cursor.getString(2);
}
profile = Cname;
Id = idText.getText().toString();
Pass = passText.getText().toString();
if (Id.equals(Cnum) && Pass.equals(Cpass)) {
isLogin = true;
Intent main = new Intent(getApplication(), MainActivity.class);
main.putExtra("splash", "splash");
startActivity(main);
Toast.makeText(getApplicationContext(), Cname + "님 환영합니다.",
Toast.LENGTH_SHORT).show();
}
else {
Toast.makeText(getApplicationContext(), "정확한 정보를 입력하세요.",
Toast.LENGTH_SHORT).show();
}
cursor.close();
}
}
<EditText
android:id="@+id/id"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:hint="아이디"
android:textSize="20dp"
android:inputType="text"/>
</LinearLayout>
이렇게 테이블을 구성하고 로그인하는 함수를 만들었고 맨밑은 xml 파일인데요.
num변수가 id인데 뭐가 문젠지 진짜 모르겠네요 ㅠㅠ