1

I'm retrieving a list of "read messages" that I store by objectID when clicking on a detail view. Now I'm attempting to retrieve these objectID's from the array like so:

JSONArray myArray = ParseUser.getCurrentUser().getJSONArray("read_messages");

But how would I iterate through each string in that array for example Log each one in the console?

Shaniqua
  • 37
  • 3
  • This question has been already answered here http://stackoverflow.com/questions/3408985/json-array-iteration-in-android-java – Zach Jul 14 '15 at 18:26

2 Answers2

1
for (int i = 0; i < myArray.length(); i++) {
    Log.d(TAG, myArray.getString(i));
}
Gennadii Saprykin
  • 4,505
  • 8
  • 31
  • 41
1

But how would I iterate through each string in that array for example Log each one in the console?

Use a loop then, E.g.

for (int i = 0; i < myArray.length(); i++) {
   Log.i("TEST", " " + myArray.optString(i)); 
}
Blackbelt
  • 156,034
  • 29
  • 297
  • 305