Retrieve USING findfirst returns weird string instead of actual string

I am retrieving an object from backendless and displaying the values in EditText in android. But It is returning a weird long random string from backend and not the actual value of the column.
Below is my code I used from code gen from backendless

BASIC_DETAILS.findFirstAsync(query, new AsyncCallback<BASIC_DETAILS>() {
[url=undefined][/url]            @Override
[url=undefined][/url]            public void handleResponse(BASIC_DETAILS basic_details) {
[url=undefined][/url]                Log.v("returned value",String.valueOf(response.getNAME()))
[url=undefined][/url]            }
[url=undefined][/url]        });

String.valueOf(response.getNAME()) returns a long string like SHSHS-SHSHS-AYWGE-WQYET-CBVKK instead of simple string like “vivek”

Thanks in advance

Hi, Vivek!

What is the “query” and how is it used inside “findFirstAsync” method?
I’m asking because Backendless library doesn’t have “findFirst” method which contains query in signature.
best regards,

Hi Alex,
Query contains a where clause with equal to id constraint
findFirstAsync Method:

public static void findFirstAsync( AsyncCallback<BASIC_DETAILS> callback )
Backendless.Data.of( BASIC_DETAILS.class ).findFirst( callback );

So which method can I use to fetch a record with particular id using where clause. I am expecting only one record in return and basic find return a backendless collection rather than an object.

Thanks & Regards,

If you want to get only one object - use method Backendless.Data.of( YourClass.class ).findById( String objectId, AsyncCallback<YourClass> responder )

I dont have the ObjectId I have a key value from one of the column based on which I want to retrieve object. I have a table basic details and I am looking for a row with, lets say id =0001. Please help me I am stuck.

Thanks & Regards,

You should use Backendless.Data.of( MyTable.class ).find( query ) method. In response you’ll get collection with target objects. If the “id” is unique and exists - your collection would contain 1 object, otherwise you’ll get empty collection, or collection with multiple objects. Request would look like the following:

String whereClause = "id=0001";
BackendlessDataQuery query = new BackendlessDataQuery( whereClause );
Backendless.Data.of( YourClass.class ).find( query, new AsyncCallback&lt;BackendlessCollection&lt;YourClass&gt;> {
public void handleResponse( BackendlessCollection&lt;YourClass&gt; response ) {
if( response.getData().size() == 1 )
YourClass object = response.getData().get( 0 );
System.out.println( "Incorrect response - only one object is expected" );
public void handleFault( BackendlessFault fault )
System.out.println( "Fault: " + fault.getMessage() );
} );

Thanks it worked!! :slight_smile: