This should be fairly simple. I have a class called "Inventory". I have two important columns. "productName" and "productPrice". I need to get the productPrice based on the productName. How would I query for the name and then retrieve the associated price? The String is always returned as null.
Update:
@Override
public String getCost() {
final String[] productValue = {null};
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>
query.whereEqualTo("productName", Capris);
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> list, ParseException e) {
if (e == null) { //no exception, hence success
productValue[0] = list.get(0).getString("productPrice");
}
}
});
return productValue[0];
}
This is more or less what I now have. Is there a better way to return a string? It's still coming back as null. I just need to return the value from the query.
Working Answer:
Returning String from Parse.com query
This was resolved in another question. In above code productValue[0] may be null as its an aysnc call So replace findInBackground with find()