Book Image

DynamoDB Cookbook

By : Tanmay Deshpande
Book Image

DynamoDB Cookbook

By: Tanmay Deshpande

Overview of this book

Table of Contents (18 chapters)
DynamoDB Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Implementing view contacts services


In this recipe, we are going to see how to implement view contacts services for our Android app.

Getting ready…

To get started with this recipe, you should have performed the earlier recipes.

How to do it…

Let's implement view contacts services:

  1. To fetch the contacts saved by a particular user, we will use the same AppContact model that we used in the earlier recipe.

  2. Next, we need to write a method that fetches all the contacts saved with a certain e-mail ID:

    public static List<AppContact> getAllContacts(String email) {
    AmazonDynamoDBClient ddb = ContactListActivity.clientManager.ddb();
        DynamoDBMapper mapper = new DynamoDBMapper(ddb);
        List<AppContact> contactList = new ArrayList<AppContact>();
        try {
          Log.d(TAG, "Fetching contacts");
        // Condition to get records for given userEmailId
          Condition condition = new Condition().withComparisonOperator(
              ComparisonOperator.EQ.toString()).withAttributeValueList(new AttributeValue...