0

皆さん、これは名前をデータベースに既に存在するものと比較するための私のコードです。ただし、getcount は常に 0 を返します。助けはありますか?ありがとう !!

public String checkUserName(SQLiteDatabase db, String enteredName)

{

        String selectionArgs[] = new String[1];
        selectionArgs[0] = enteredName;
        Cursor cursor = db.rawQuery("select * from table1 where user=?", selectionArgs);
        cursor.moveToFirst();
        return Integer.toString(cursor.getCount());
    }

上記の関数を呼び出すために使用するコードは次のとおりです。

    Intent intent = getIntent();
    TextView tv1 = new TextView(this);
    String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE)
tv1.setText(db.checkUserName(db.getWritableDatabase(), message));
relativeLayout.addView(tv1)

DB スナップショット リンク: http://i.stack.imgur.com/LnTbl.jpg

4

1 に答える 1