Page updated Nov 14, 2023

To-do app

This is a simple to-do app that allows users to add and remove items in a to-do list. Find the source code of To-do app on our GitHub repository.

Run to-do app locally

  1. Follow the steps in Amplify Android Getting Started Tutorial to sign up for an AWS account, install and configure Amplify CLI. Install all the prerequisites for setting up a fullstack project.

  2. Open Terminal and clone the project under your preferred directory using the following command:

    1git clone https://github.com/aws-amplify/amplify-android-samples.git

    Change directory to root folder of whichever language you want to use.

1cd amplify-android-samples/getting-started/todo/java
1cd amplify-android-samples/getting-started/todo/kotlin
  1. Follow the instructions to generate model files.

  2. Connect the project to the cloud by running the command:

    1amplify push

    Answer No to ? Do you want to generate code for your newly created GraphQL API. Answering Yes will generate an API.java file which is only necessary when directly using the AWS AppSync SDK. When you're using Amplify API or Amplify DataStore, you'll use the amplify codegen models command to generate Java models.

    After this step, you will see the following in the terminal if the project is successfully connected to the cloud:

1GraphQL schema compiled successfully.
2
3Edit your schema at amplify-android-samples/getting-started/todo/java/amplify/backend/api/todoapp/schema.graphql or place .graphql files in a directory at amplify-android-samples/getting-started/todo/java/amplify/backend/api/todoapp/schema
4Successfully generated models. Generated models can be found in amplify-android-samples/getting-started/todo/java/app/src/main/java
5Post-pull status:
6
7 Current Environment: dev
8
9┌──────────┬───────────────┬───────────┬───────────────────┐
10CategoryResource name │ OperationProvider plugin │
11├──────────┼───────────────┼───────────┼───────────────────┤
12Api │ todoapp │ No Change │ awscloudformation │
13└──────────┴───────────────┴───────────┴───────────────────┘
1GraphQL schema compiled successfully.
2
3Edit your schema at amplify-android-samples/getting-started/todo/kotlin/amplify/backend/api/todoapp/schema.graphql or place .graphql files in a directory at amplify-android-samples/getting-started/todo/kotlin/amplify/backend/api/todoapp/schema
4Successfully generated models. Generated models can be found in amplify-android-samples/getting-started/todo/kotlin/app/src/main/java
5Post-pull status:
6
7 Current Environment: dev
8
9┌──────────┬───────────────┬───────────┬───────────────────┐
10CategoryResource name │ OperationProvider plugin │
11├──────────┼───────────────┼───────────┼───────────────────┤
12Api │ todoapp │ No Change │ awscloudformation │
13└──────────┴───────────────┴───────────┴───────────────────┘
  1. Build and run the to-do app on an emulator or Android device in Android Studio.

App features

This app demonstrates the following features:

  • Create a task with priority
  • Sort tasks by date created, priority, or alphabetically
  • Complete a task
  • Delete a task

These features are implemented using Amplify DataStore.

  • Creating tasks and completing tasks are achieved with Amplify.DataStore.save().
  • Sorting tasks is achieved with Amplify.DataStore.query() and using Where.sorted() as the query predicate.
  • Deleting a task is achieved with Amplify.DataStore.delete().

UI experience

Shows screen by screen workflow of how Android Sample App would look like