我正在使用Firebase進行身份驗證和實時數據庫。我的驗證碼已成功也跑我的輸入值,數據庫代碼也運行,但是當我編碼在數據庫中獲取價值,我得到運行時錯誤嘗試在火力地堡數據庫輸入值:獲取數據庫時無效的Firebase路徑錯誤
FATAL EXCEPTION: main
Process:com.xxx.xxx, PID: 22601
com.google.firebase.database.DatabaseException: Invalid Firebase Database
path: https://xxx-exxe.firebaseio.com/. Firebase Database paths must not contain '.', '#', '$', '[', or ']'
我的代碼是:
final FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference reference = database.getReference("https://korsa-e03ae.firebaseio.com/");
reference.addValueEventListener(new com.google.firebase.database.ValueEventListener() {
@Override
public void onDataChange(com.google.firebase.database.DataSnapshot dataSnapshot) {
Offerride user = dataSnapshot.getValue(Offerride.class);
if (user == null){
Toast.makeText(getContext(),"User data is null!",Toast.LENGTH_LONG).show();
return;
}
tvsource.setText(user.source + " , " + user.destination + " , " + user.startDate + " , " + user.startTime);
}
@Override
public void onCancelled(DatabaseError databaseError) {
Toast.makeText(getContext(), "Failefddd", Toast.LENGTH_LONG).show();
}
});
爲什麼是它的'ValueEventListener()'和'DataSnapshot'正與'com.google.firebase.database.'前綴使用?刪除它時會拋出錯誤嗎? –
您的firebase路徑值包含以下字符之一'。','#','$','['或']'.so引用路徑不包含這些字符。當您呼籲這條道路的孩子 –