0

I have a Fragment, and once the user presses OK, an Item is added to my database and its ID is added to the ArrayAdapter. Immediately after, the adapter tries to draw the view, but the first time it tries to get its attributes, it returns a null HashMap (it gets drawn properly the following times).

Is there a way to make sure the item is in the table before trying to get its attributes? Even putting the attribute retrieval into a while loop until it returns a not-null HashMap doesn't work so it doesn't look to be an issue of time.

Phillip Godzin
  • 660
  • 1
  • 9
  • 21

2 Answers2

1

You need to do Select or GetAttributes with ConsistentRead=true as Amazon SimpleDB supports two read consistency options: eventually consistent read and consistent read. Eventually consistent read is default. For more detail please refer doc. link

Ashish Pancholi
  • 4,569
  • 13
  • 50
  • 88
0

Try using AsynTask.

  • Add item to database in doInBackground.

  • Read it in postExecute.

You are done.

Praveena
  • 6,340
  • 2
  • 40
  • 53