Hello,
In a table called ANSWERS all rows are identified with an unique Id. With entering an Id, I want to retrieve all of the columns for this row and save it in different variables.
My code is:
String whereClause = "Id = 'id2'";
DataQueryBuilder queryBuilder = DataQueryBuilder.create();
queryBuilder.setWhereClause(whereClause);
Backendless.Data.of( "ANSWERS" ).find( queryBuilder,
new AsyncCallback<List<Map>>(){
@Override
public void handleResponse( List<Map> foundContacts )
{
// every loaded object from the "Contact" table is now an individual java.util.Map
}
@Override
public void handleFault( BackendlessFault fault )
{
// an error has occurred, the error code can be retrieved with fault.getCode()
}
});
I get this error when run my app:
java.lang.ClassCastException: java.lang.Object[] cannot be cast to java.util.List
I just tried this operation with the latest version of the SDK for Android and it works just fine. Could you please check what version of the SDK you’re building with?
You should reference the columns by their names. I would recommend inspecting the contents of “foundContacts” with a debugger to see how the data is structured.
Here’s the code to get the first object from the returned collection and then getting a value for a column:
Map firstObject = foundContacts.get( 0 );
//assuming the value in the column is String
String columnValue = (String) firstObject.get( "COLUMN NAME GOES HERE" );