firebase创建数据库_如何使用Firebase Firestore设置数据库以与android体系结构组件一起使用...

firebase创建数据库

In a previous article, we discussed how to create an Android app with two of the most important building blocks of Android Architecture Components: LiveData and ViewModel. This is a follow-up to that tutorial.

上一篇文章中 ,我们讨论了如何使用Android体系结构组件的两个最重要的构建块来创建Android应用程序:LiveData和ViewModel。 这是该教程的后续内容。

Once we have an app with clean architecture, we will be configuring Firebase Firestore for Android Architecture Components to update data in real-time and make the most out of LiveData and ViewModel in Android.

有了拥有干净架构的应用程序后,我们将为Android体系结构组件配置Firebase Firestore,以实时更新数据并充分利用Android中的LiveData和ViewModel。

启动 (Starting Up)

We will start this tutorial with the app we built for the previous tutorial, My Shopping List. Download the starter project from my website.

我们将从为上一教程构建的应用程序“我的购物清单”开始本教程。 从我的网站下载入门项目。

Open the app in Android Studio and let the Gradle sync finish. Run the app and you should see an app with a shopping list:

在Android Studio中打开该应用,然后让Gradle同步完成。 运行该应用程序,您应该会看到一个带有购物清单的应用程序:

Image for post
Image 1: My Shopping List app.
图片1:“我的购物清单”应用。

在Firebase控制台中创建项目 (Creating a Project in the Firebase Console)

The first step is to create a Firebase Console Project. Go to the Firebase Console main page. On this screen, you will get one of two layouts:

第一步是创建Firebase控制台项目。 转到Firebase控制台主页 。 在此屏幕上,您将获得两种布局之一:

  1. If you have never used the Firebase Console before, you will be prompted with a welcome message and an invitation to create a project.

    如果您以前从未使用过Firebase控制台,则系统将提示您一条欢迎消息和创建项目的邀请。
Image for post
Image 2: Firebase Console welcome screen with no projects.
图2:没有项目的Firebase控制台欢迎屏幕。

2. If you have other projects, you will see a list of them and a white card to add a project.

2.如果您还有其他项目,则将看到其中的列表和一张添加项目的白卡。

Image for post
Image 3: Firebase Console welcome screen with other projects.
图3:Firebase Console欢迎屏幕以及其他项目。

Click the button to create a project depending on the option you have and you will start the flow for creating a project. The first screen will prompt you for the name of the project. In this case, you will use the same name of your Android app, which is MyShoppingList.

单击按钮创建一个项目,具体取决于您拥有的选项,然后将开始创建项目的流程。 第一个屏幕将提示您输入项目名称。 在这种情况下,您将使用与Android应用程序相同的名称,即MyShoppingList。

Image for post
Image 4: Naming the Firebase project.
图4:命名Firebase项目。

Click Continue and the next step will ask you whether you want to enable Google Analytics. This is not necessary for Firestore, but you may want to enable it for other reasons:

点击继续,下一步将询问您是否要启用Google Analytics(分析)。 对于Firestore,这不是必需的,但是您可能由于其他原因而希望启用它:

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值