Backendless Support
 
Solved

HOW TO SEARCH WITH STRING

87c283b30cff3776b95686e459617b4a

This is my value in table QUOTE. Now i want to search a quote with a string? How can I do that?

https://backendless.com/docs/android/doc.html#data_search_with_where_clause This is API but it's not clear. Assume I input a string "love" in SearchView and i will get all quote contains "love".

Leave a Comment

Comments (8)

photo
1

Hello!

If you're using SQL Search you should write the SQL search command, e.g. "quoteCategoryName = 'Yoga'".

When the SQL Search checkbox is unchecked you can search without SQL command.

Examples attached.

Regards, Olga

photo
1

I want to search in my phone, and get data from sever. E.g: The User input a String "love" and they will get all value contain "love" in table. How can do that?

photo
photo
1

Use DataQueryBuilder with where clause. Take a look at these examples.

Regards, Olga

photo
1

You don't understand my question, do you?

photo
photo
1

Hello,

  1. I want to search in my phone, and get data from sever. E.g: The User input a String "love" and they will get all value contain "love" in table. How can do that?

to search on your phone, you have to write an application. As I understand you are using android. Here https://backendless.com/docs/android/doc.html#data_search_with_where_clause you can find answer for your question http://take.ms/3h8ub

photo
1

ed362ede25ef7bf70a52a25e796b1251

I want to search like this in my app on android. I try this but it's not work

private void getQuoteWithString(String inputContent) {

final DataQueryBuilder queryBuilder = DataQueryBuilder.create();

queryBuilder.setSortBy("created DESC");

queryBuilder.setWhereClause("quoteContent = '" + inputContent + "'");

Backendless.Persistence.of(Constants.TABLE_QUOTE).find(queryBuilder, new AsyncCallback<List<Map>>() {

@Override

public void handleResponse(List<Map> response) {

for (int i = 0; i < response.size(); i++) {

Quote quote = new Quote();

quote.setQuoteId(response.get(i).get("objectId").toString());

quote.setQuoteCategoryName(response.get(i).get("quoteCategoryName").toString());

quote.setQuoteContent(response.get(i).get("quoteContent").toString());

quote.setQuoteAuthorName(response.get(i).get("quoteAuthorName").toString());

quote.setQuoteTimeCreated(response.get(i).get("created").toString());

mQuoteList.add(quote);

}

adapterQuote = new AdapterQuote(SearchQuoteActivity.this, mQuoteList);

lsvSearch.setAdapter(adapterQuote);

}

@Override

public void handleFault(BackendlessFault fault) {

}

});

}

photo
1

And what do you get in response?

Also do not ignore fault

  1. public void handleFault(BackendlessFault fault) {

    }

you should handle it( fault.getDetails() or fault.getMessage() or both), write to a log or show a toaster. In other case you may miss something

photo
1

Yeah, thank for sp

photo