简体   繁体   English

android-将数据保存到firebase用字母键保存

[英]android - saving data to firebase is saved with alphabet keys

my data is saved to firebase this way: 我的数据通过以下方式保存到Firebase:

a: "Tom"
b: "26"
...

I know that in order to save it with the correct keys ("mName" instead of "a", "mAge" instead of "b" and so on) I have to add the next lines to my proguard according to the documentation https://firebase.google.com/docs/database/android/start/#proguard 我知道,为了使用正确的键(“ mName”而不是“ a”,“ mAge”而不是“ b”等进行保存),我必须根据文档https将下一行添加到我的proguard中: //firebase.google.com/docs/database/android/start/#proguard

# Add this global rule
-keepattributes Signature

# This rule will properly ProGuard all the model classes in
# the package com.yourcompany.models. Modify to fit the structure
# of your app.
-keepclassmembers class com.yourcompany.models.** {
 *;
}

my questions is: 我的问题是:

  1. Assuming that my package name is com.testing , should the added lines look like these? 假设我的包名称是com.testing ,添加的行应该看起来像这样吗?

    -keepattributes Signature -keepattributes签名

    -keepclassmembers class com.testing.models.** { *; -keepclassmembers类com.testing.models。** {*; } }

OR the second line should be without the "models"? 或者第二行应该没有“模型”? like this: 像这样:

-keepclassmembers class com.testing.** {
  1. Moreover, if I have only 1 global class named Data that I save to firebase, can I just keep these class members specifically? 此外,如果我只有一个保存到firebase的名为Data的全局类,是否可以仅保留这些类成员? or I must act as shown above.. 否则我必须按照上述方式行事。

yes, it will look like this 是的,它看起来像这样

-keepattributes Signature

-keepclassmembers class com.testing.models.** { *; }

If you have only one model class called Data, add the following lines instead 如果只有一个名为Data的模型类,请添加以下几行

-keepattributes Signature

-keep class com.testing.models.Data { *; }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM