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.
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.
Follow the instructions to generate model files.
Connect the project to the cloud by running the command:1amplify push
? Do you want to generate code for your newly created GraphQL API. Answering
Yeswill generate an
API.javafile 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 modelscommand 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.23Edit 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/schema4Successfully generated models. Generated models can be found in amplify-android-samples/getting-started/todo/java/app/src/main/java5Post-pull status:67 Current Environment: dev89┌──────────┬───────────────┬───────────┬───────────────────┐10│ Category │ Resource name │ Operation │ Provider plugin │11├──────────┼───────────────┼───────────┼───────────────────┤12│ Api │ todoapp │ No Change │ awscloudformation │13└──────────┴───────────────┴───────────┴───────────────────┘
- Build and run the to-do app on an emulator or Android device in Android Studio.
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
- Sorting tasks is achieved with
Where.sorted()as the query predicate.
- Deleting a task is achieved with