我想使用Java或Kotlin编程语言为我的android项目数据树存储数据树的数据,如下所示,
"posts": {
"typeScript": {
"metrics": {
"views" : 1200000,
"likes" : 251000,
"shares": 1200,
},
"title" : "TypeScript Functions",
"author": "tim",
},
"android": {
"metrics": {
"views" : 900000,
"likes" : 117000,
"shares": 144,
},
"title" : "Android app can developed by android studio or flutter",
"author": "scott",
}
}
pz,帮帮我吧。
答案 0 :(得分:0)
答案 1 :(得分:0)
您能告诉我们您的结构数据是哪个?类〜? 打字稿和android是2类还是只有1?
private final DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference();
private DatabaseReference typeListReference = databaseReference.child("typeScript");
private DatabaseReference androidListReference =
databaseReference.child("android");
private void writeNewAndroid(String views, String likes, String share, String title, String others)
{
try {
Android android = new Android (views, , likes, share, title, others);
androidListReference.child("metrics").setValue(android );
}catch (Exception e)
{
e.printStackTrace();
}
}