Page updated Nov 9, 2023

List files

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.

You can list all of the objects uploaded under a given prefix. This will list all public files:

Amplify.Storage.list("", result -> { for (StorageItem item : result.getItems()) { Log.i("MyAmplifyApp", "Item: " + item.getKey()); } }, error -> Log.e("MyAmplifyApp", "List failure", error) );
1Amplify.Storage.list("",
2 result -> {
3 for (StorageItem item : result.getItems()) {
4 Log.i("MyAmplifyApp", "Item: " + item.getKey());
5 }
6 },
7 error -> Log.e("MyAmplifyApp", "List failure", error)
8);

You can also list private or protected files by passing options. For example, to list all protected files owned by a user identified by the ID otherUserID:

StorageListOptions options = StorageListOptions.builder() .accessLevel(StorageAccessLevel.PROTECTED) .targetIdentityId("otherUserID") .build(); Amplify.Storage.list( "", options, result -> { for (StorageItem item : result.getItems()) { Log.i("MyAmplifyApp", "Item: " + item.getKey()); } }, error -> Log.e("MyAmplifyApp", "List failure", error) );
1StorageListOptions options = StorageListOptions.builder()
2 .accessLevel(StorageAccessLevel.PROTECTED)
3 .targetIdentityId("otherUserID")
4 .build();
5
6Amplify.Storage.list(
7 "",
8 options,
9 result -> {
10 for (StorageItem item : result.getItems()) {
11 Log.i("MyAmplifyApp", "Item: " + item.getKey());
12 }
13 },
14 error -> Log.e("MyAmplifyApp", "List failure", error)
15);