SQLite Query Exception Android Studio Syntax Error code 1

后端 未结 1 1531
情书的邮戳
情书的邮戳 2021-01-29 13:40

So im trying to build a search method for my android app and i keep running into this error

android.database.sqlite.SQLiteException: near \"Prefect\": syntax err         


        
相关标签:
1条回答
  • 2021-01-29 13:53

    There should be single quote while passing the values .i.e., your query should be passed in this way "*SELECT * FROM Person WHERE name = 'Ford Prefect';*". Below I have edited your question.

    public Cursor findUser(String uName) {
        Cursor res = myDatabase.query("Person WHERE name = '"+uName+"';",
                                             null,null,null,null,null,null);
        return res;
    }
    
    0 讨论(0)
提交回复
热议问题