Query Like on Android Sqlite

Asked

Viewed 338 times

0

I’m trying to do a query like on sqlite.

Cursor cursor = database.rawQuery("SELECT nome FROM Armas WHERE nome LIKE ?", new String[]{name});

That String I pass like this:

 data = getIntent().getStringExtra("name");
        final List<String> getFinalResult = databaseAccess.pesquisaArmas("%" + data + "%");

But it’s not returning with the like, it’s returning all the records. What is the way to return only what was passed in the date variable?

  • Try putting simple quotes " '%" + data + "%' "

  • did not work, did not return any record

  • But inside name has something written?! Because the logic is this same, put in quotes or simple, or put "\"%" + data + "%\""

  • put a Toast and is passing yes. The variable is receiving a text.

  • Man, I’m almost, I say almost, sure the mistake is because of the quotation marks.

  • I pulled out the quotes, I gave a clean build and it worked =/

  • Did you take or put? Now you confused. ehueh

  • 1

    I took it. The way I had done was just give a clean build and it worked

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.