Page updated Jan 16, 2024

Update data

Amplify Android v1 is now in Maintenance Mode until May 31st, 2024. This means that we will continue to include updates to ensure compatibility with backend services and security. No new features will be introduced in v1.

Please use the latest version (v2) of Amplify Library for Android to get started.

If you are currently using v1, follow these instructions to upgrade to v2.

Amplify libraries should be used for all new cloud connected applications. If you are currently using the AWS Mobile SDK for Android, you can access the documentation here.

PUT requests

To update an item via the API endpoint:

1RestOptions options = RestOptions.builder()
2 .addPath("/todo/1")
3 .addBody("{\"name\":\"Mow the lawn\"}".getBytes())
4 .build();
5
6Amplify.API.put(options,
7 response -> Log.i("MyAmplifyApp", "PUT succeeded: " + response),
8 error -> Log.e("MyAmplifyApp", "PUT failed.", error)
9);
1val request = RestOptions.builder()
2 .addPath("/todo/1")
3 .addBody("{\"name\":\"Mow the lawn\"}".toByteArray())
4 .build()
5
6Amplify.API.put(request,
7 { Log.i("MyAmplifyApp", "PUT succeeded: $it") },
8 { Log.e("MyAmplifyApp", "PUT failed", it) }
9)
1val request = RestOptions.builder()
2 .addPath("/todo/1")
3 .addBody(JSONObject()
4 .put("name", "Mow the lawn")
5 .toString()
6 .toByteArray())
7 .build()
8try {
9 val response = Amplify.API.put(request)
10 Log.i("MyAmplifyApp", "PUT succeeded: $response")
11} catch (error: ApiException) {
12 Log.e("MyAmplifyApp", "PUT failed", it)
13}
1RestOptions options = RestOptions.builder()
2 .addPath("/todo/1")
3 .addBody("{\"name\":\"Mow the lawn\"}".getBytes())
4 .build();
5
6RxAmplify.API.put(options)
7 .subscribe(
8 response -> Log.i("MyAmplifyApp", "PUT succeeded: " + response),
9 error -> Log.e("MyAmplifyApp", "PUT failed.", error)
10 );