latest Backendless , using java
this is my code but getting null, while in backendless it’s working :(:
if (!Backendless.UserService.isValidLogin()) {return;}
BackendlessUser user = Backendless.UserService.CurrentUser();
DataQueryBuilder query = DataQueryBuilder.create();
query.setPageSize(100);
query.addRelated("stores");
try {
query.setWhereClause("objectId='" + user.getObjectId() + "'");
Log.e("sql", "getStoreList: objectId='"+user.getObjectId()+"'");
} catch (Exception e) {
Toast.makeText(MainActivity.context, "err", Toast.LENGTH_SHORT).show();
Log.e("err", "getStoreList: " + e.getMessage());
}
//Stores userStores =(Stores) user.getProperty("stores");
Backendless.Data.of("Users").find(query, new AsyncCallback<List<Map>>() {
@Override
public void handleResponse(List<Map> response) {
storeNames = new ArrayList<>();
try {
HashMap[] userStores = (HashMap[]) response.get(0).get("stores");
for (int counter = 0; counter < userStores.length; counter++) {
com.befood.app.backendless.StoreList newStore = new com.befood.app.backendless.StoreList((String) userStores[counter].get("storeName"),
(String) userStores[counter].get("storeImage"),
(String) userStores[counter].get("objectId"),
(String) userStores[counter].get("storeGPS"));
storeNames.add(newStore);
}
} catch (Exception e) {
Log.e("err", "handleResponse: no stores");
}
if (storeNames.size() < 1) {
findViewById(R.id.imgStores).setVisibility(View.VISIBLE);
return;
}
findViewById(R.id.imgStores).setVisibility(View.INVISIBLE);
StoreManageListAdapter adapter = new StoreManageListAdapter(context, storeNames);
lstUserStores.setAdapter(adapter);
}
@Override
public void handleFault(BackendlessFault fault) {
Toast.makeText(MainActivity.context, "err", Toast.LENGTH_SHORT).show();
Log.e("err", "handleFault: " + fault.getMessage());
}
});