This quickstart is a movie review app to demonstrate the use of Firebase Data Connect with a Cloud SQL database. For more information about Firebase Data Connect visit the docs.
Follow these steps to get up and running with Firebase Data Connect. For more detailed instructions, check out the official documentation.
- Latest version of Android Studio
- Latest version of Visual Studio Code
- The Firebase Data Connect VS Code Extension
-
If you haven't already, create a Firebase project.
- In the Firebase console, click Add project, then follow the on-screen instructions.
-
Upgrade your project to the Blaze plan. This lets you create a Cloud SQL for PostgreSQL instance.
Note: Though you set up billing in your Blaze upgrade, you won't be charged for usage of Firebase Data Connect or the default Cloud SQL for PostgreSQL configuration during the preview.
-
Navigate to the Data Connect section of the Firebase console, click on the "Get Started" button and follow the setup workflow:
- Select a location for your Cloud SQL for PostgreSQL database (this sample uses
us-central1
). If you choose a different location, you'll also need to change thequickstart-android/dataconnect/dataconnect/dataconnect.yaml
file. - Select the option to create a new Cloud SQL instance and fill in the following fields:
- Service ID:
dataconnect
- Cloud SQL Instance ID:
fdc-sql
- Database name:
fdcdb
- Service ID:
- Select a location for your Cloud SQL for PostgreSQL database (this sample uses
-
Allow some time for the Cloud SQL instance to be provisioned. After it's provisioned, the instance can be managed in the Cloud Console.
-
If you haven’t already, add an Android app to your Firebase project, with the android package name
com.google.firebase.example.dataconnect
. Click Download google-services.json to obtain your Firebase Android config file.
-
Clone this repository to your local machine:
git clone https://github.com/firebase/quickstart-android.git
-
Move the
google-services.json
config file (downloaded in the previous step) into thequickstart-android/dataconnect/app/
directory.
- Open the
quickstart-android/dataconnect
directory in VS Code. - Click on the Firebase Data Connect icon on the VS Code sidebar to load the Extension. a. Sign in with your Google Account if you haven't already.
- Click on "Connect a Firebase project" and choose the project where you have set up Data Connect.
- Click on "Start Emulators" - this should generate the Kotlin SDK for you and start the emulators.
In VS Code, open the quickstart-android/dataconnect/dataconnect/moviedata_insert.gql
file and click the
Run (local)
button at the top of the file.
If you’d like to confirm that the data was correctly inserted,
open quickstart-android/dataconnect/movie-connector/queries.gql
and run the ListMovies
query.
Press the Run button in Android Studio to run the sample app on your device.