<BlockSwitcher>
<Block name="Java">

```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)
);
```

</Block>
<Block name="Kotlin - Callback">

```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) }
)
```

</Block>
<Block name="Kotlin - Coroutines">

```kotlin
Amplify.DataStore.query(Post::class)
    .catch { Log.e("MyAmplifyApp", "Query failed", it) }
    .collect { Log.i("MyAmplifyApp", "Title: ${it.title}") }
```

</Block>
<Block name="RxJava">

```java
RxAmplify.DataStore.query(Post.class).subscribe(
    post -> Log.i("MyAmplifyApp", "Title: " + post.getTitle()),
    failure -> Log.e("MyAmplifyApp", "Query failed.", failure)
);
```

</Block>
</BlockSwitcher>
