```java QueryOptions queryOptions = null; try { queryOptions = Where.identifier(Post.class, "123"); } catch (AmplifyException e) { Log.e("MyAmplifyApp", "Failed to construct QueryOptions with provided values for Where.identifier", e); } if (queryOptions != null) { Amplify.DataStore.query(Post.class, queryOptions, match -> { if (match.hasNext()) { Post post = match.next(); Amplify.DataStore.delete(post, deleted -> Log.i("MyAmplifyApp", "Post deleted."), failure -> Log.e("MyAmplifyApp", "Delete failed.", failure) ); } }, failure -> Log.e("MyAmplifyApp", "Query failed.", failure) ); } ``` ```kotlin Amplify.DataStore.query(Post::class.java, Where.identifier(Post::class.java, "123"), { if (it.hasNext()) { val post = it.next() Amplify.DataStore.delete(post, { Log.i("MyAmplifyApp", "Post deleted") }, { Log.e("MyAmplifyApp", "Delete failed") } ) } }, { Log.e("MyAmplifyApp", "Query failed", it) } ) ``` ```kotlin Amplify.DataStore.query(Post::class, Where.identifier(Post::class.java, "123")) .catch { Log.e("MyAmplifyApp", "Query failed", it) } .onEach { Amplify.DataStore.delete(it) } .catch { Log.e("MyAmplifyApp", "Delete failed", it) } .collect { Log.i("MyAmplifyApp", "Post deleted") } ``` ```java QueryOptions queryOptions = null; try { queryOptions = Where.identifier(Post.class, "123"); } catch (AmplifyException e) { Log.e("MyAmplifyApp", "Failed to construct QueryOptions with provided values for Where.identifier", e); } if (queryOptions != null) { RxAmplify.DataStore.query(Post.class, queryOptions) .flatMapCompletable(RxAmplify.DataStore::delete) .subscribe( () -> Log.i("MyAmplifyApp", "Post deleted."), failure -> Log.e("MyAmplifyApp", "Delete failed.", failure) ); } ```