我试图创建一个检索通话记录并将其发送到服务器(特定网址)的应用。我设法以字符串的形式获取通话记录,但无法确定如何将这些数据发送到firebase的数据库。是否可以这样做?
答案 0 :(得分:1)
为Android应用设置firebase后,写入firebase的代码为
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference ref = database.getReference("callRecords");
Map<String, Object> callRecords = new HashMap<>();
//if you have a specific, unique label for your call record
callRecords.put(label1,callRecordString1)
callRecords.put(label2,callRecordString2)
//... put more call records
//OR... if you dont have a label, get a random key with Firebase
callRecords.put(ref.push().getKey() , callRecordString1)
callRecords.put(ref.push().getKey() , callRecordString2)
//... put more call records
ref.updateChildren(callRecords);