```java Amplify.DataStore.query(Post.class, allPosts -> { while (allPosts.hasNext()) { Post post = allPosts.next(); Log.i("MyAmplifyApp", "Title: " + post.getTitle()); } }, failure -> Log.e("MyAmplifyApp", "Query failed.", failure) ); ``` ```kotlin Amplify.DataStore.query(Post::class.java, { allPosts -> while (allPosts.hasNext()) { val post = allPosts.next() Log.i("MyAmplifyApp", "Title: ${post.title}") } }, { Log.e("MyAmplifyApp", "Query failed", it) } ) ``` ```kotlin Amplify.DataStore.query(Post::class) .catch { Log.e("MyAmplifyApp", "Query failed", it) } .collect { Log.i("MyAmplifyApp", "Title: ${it.title}") } ``` ```java RxAmplify.DataStore.query(Post.class).subscribe( post -> Log.i("MyAmplifyApp", "Title: " + post.getTitle()), failure -> Log.e("MyAmplifyApp", "Query failed.", failure) ); ```