我正在开发一个将数据存储到firebase并检索它的应用程序
我在使用firebase回收器适配器从firebase获取(接收)数据时收到错误
错误
com.google.firebase.database.DatabaseException: Invalid Firebase
Database path:
{UserName=Mohit,VideoPath=https://firebasestorage.googleapis.com/v0/b/foodyyoucantstayhungry.appspot.com/o/Video_Upload%2FStreet%2F12%20Apr%2F08%3A48%20AM%2Fvideo%3A35373.mp4?alt=media&token=9192cfb8-cf5e-4585-998f-8f86eb802372, Short_Desc=jgatajy, DateTime=12 Apr 08t48 AM, VideoName=jrHrngnTu, Long_Desc=iysyisuoo, Views=0, Likes=0}. Firebase Database paths must not contain '.', '#', '$', '[', or ']'
at com.google.android.gms.internal.zf.zzhb(Unknown Source)
at com.google.firebase.database.DatabaseReference.child(Unknown Source)
at com.foodies.mohitgupta.foodyyoucantstsyhungry.MainArea$2.onChildAdded(MainArea.java:200)
at com.google.android.gms.internal.px.zza(Unknown Source)
at com.google.android.gms.internal.vj.zzHX(Unknown Source)
at com.google.android.gms.internal.vp.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5740)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766)
Firebase结构
Video_Upload
Street
12 Apr 08:48 AM
DateTime:value
likes:value
Long_Desc:value
Short_desc:value
UserName:value
VideoName:value
VideoPath:value
Views:values
我在以下代码MainArea.java
中收到此错误
@Override
protected void onStart() {
super.onStart();
final DatabaseReference[] StreetRef1 = new DatabaseReference[1];
StreetRef=FirebaseDatabase.getInstance().getReference().child("Video_Upload").child("Street");
StreetRef.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded( DataSnapshot dataSnapshot, String s ) {
String Date=dataSnapshot.getValue().toString();
StreetRef1[0] =FirebaseDatabase.getInstance().getReference("Video_Upload").child("Street").child(Date);
FirebaseRecyclerAdapter<StreetDataFetcher,StreetRecycler> FBRA=new FirebaseRecyclerAdapter<StreetDataFetcher, StreetRecycler>(
StreetDataFetcher.class,
R.layout.card_recycler_view,
StreetRecycler.class,
StreetRef1[0]
) {
@Override
protected void populateViewHolder( StreetRecycler viewHolder, StreetDataFetcher model, int position ) {
viewHolder.setUserName(model.getUserName());
viewHolder.setDateTime(model.getDateTime());
viewHolder.setVideoName(model.getVideoName());
viewHolder.setShort_Desc(model.getShort_Desc());
}
};
StreetRecyclerView.setAdapter(FBRA);
}
@Override
public void onChildChanged( DataSnapshot dataSnapshot, String s ) {
}
@Override
public void onChildRemoved( DataSnapshot dataSnapshot ) {
}
@Override
public void onChildMoved( DataSnapshot dataSnapshot, String s ) {
}
@Override
public void onCancelled( DatabaseError databaseError ) {
}
});
}
**the View Holder class i the following code is**
**StreetRecycler.class**
/**
* Recycler View Holder
*/
public static class StreetRecycler extends RecyclerView.ViewHolder{
View mView;
TextView UsernameText,date,VideoName,Title,ShortDescription;
public StreetRecycler( View itemView ) {
super(itemView);
mView=itemView;
}
public void setUserName( String userName )
{
UsernameText=(TextView)mView.findViewById(R.id.UsernameText);
UsernameText.setText(userName);
}
public void setDateTime( String dateTime )
{
date=(TextView)mView.findViewById(R.id.date);
date.setText(dateTime);
}
public void setVideoName( String videoName )
{
Title=(TextView)mView.findViewById(R.id.Title);
Title.setText(videoName);
}
public void setShort_Desc( String short_Desc )
{
ShortDescription=(TextView)mView.findViewById(R.id.ShortDescription);
ShortDescription.setText(short_Desc);
}
}
答案 0 :(得分:0)
根据错误消息
我认为Firebase数据库名称具有一些空间特征。
或我认为您需要在代码中使用数据库名称。
.getReference(FIRE_DB_NAME);
在这一行。
StreetRef=FirebaseDatabase.getInstance().getReference().child("Video_Upload").child("Street");
答案 1 :(得分:0)
Firebase数据库路径不得包含“。”,“#”,“ $”,“ [”或“]”