I'm developing an application using DynamoDB, in a few words: i'm getting information from the database and I want to display this information.
I don't know what I supposed to do but i have an error inside the AsyncTask, the app is crushing always when i want to save this strings in an ArrayList. Here is my code:
private class db extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... params) {
AmazonDynamoDBClient ddbClient = new AmazonDynamoDBClient(credentialsProvider);
ddbClient.setRegion(Region.getRegion(Regions.EU_CENTRAL_1));
DynamoDBMapper mapper = new DynamoDBMapper(ddbClient);
Condition hashKeyCondition = new Condition()
.withComparisonOperator(ComparisonOperator.EQ.toString())
.withAttributeValueList(new AttributeValue().withN("1"));
Map<String, Condition> keyCondition = new HashMap<String,Condition>();
keyCondition.put("RestaurantID",hashKeyCondition);
Map<String, AttributeValue> lastEvaluatedKey = null;
do{
QueryRequest queryRequest = new QueryRequest()
.withTableName("Menu_Category")
.withKeyConditions(keyCondition)
.withExclusiveStartKey(lastEvaluatedKey);
QueryResult queryResult = ddbClient.query(queryRequest);
for (Map<String, AttributeValue> item : queryResult.getItems()) {
//Log.i(TAG,"Name = " + item.get("name").getS());
String i = item.get("name").getS();
//menu.add(i);
Log.i(TAG,"Name = " + i);
}
}while(lastEvaluatedKey != null);
return "Executed";
}
@Override
protected void onPostExecute(String result) {
Log.i(TAG,"onPostExecute = " + result);
}
@Override
protected void onPreExecute() {
Log.i(TAG,"inPreExecute");
}
@Override
protected void onProgressUpdate(Void... values) {
}
}
If I comment the line who is adding the String the app doesn't crush. Any idea about this error? This is frustrating.
thanks in advance.
PD: menu is declared private in the activity class.
Aucun commentaire:
Enregistrer un commentaire