以下のJsonを参照し、onDataChangeを呼び出せるようにしたいです。
公式ドキュメントを見ると、子のデータが変更されなくとも、初回は必ず呼ばれるとのことですが、一度も呼ばれず原因も不明なため解決方法を教えていただきたいです。
よろしくお願いいたします。
Java
1 //参照先DB定義 2 myRef = database.getReference("users/"); 3 4 //DBを読み出し(初期読み出しのみ) 5 myRef.addValueEventListener(new ValueEventListener() { 6 @Override 7 public void onDataChange(DataSnapshot dataSnapshot) { 8 Toast.makeText(activity, "abcdefggggggg。", Toast.LENGTH_LONG).show(); 9 } 10 }
JavaScript
1{ 2 "rooms" : { 3 "roomID1" : { 4 "name": "hello!", 5 "roomDate": 20170520, 6 "members" : { 7 "userID1" : true, 8 "userID2" : true, 9 "userID3" : true 10 } 11 }, 12 "roomID2" : { 13 "name": "hello!", 14 "roomDate": 20170520, 15 "members" : { 16 "userID4" : true, 17 "userID5" : true, 18 "userID6" : true 19 } 20 } 21 }, 22"messages": { 23 "roomID1": { 24 "messageID1": { 25 "message": "The relay seems to be malfunctioning.", 26 "timestamp": 201705031601, 27 "from": "userID1" 28 }, 29 "messageID2": { 30 "message": "The relay seems to be malfunctioning.", 31 "timestamp": 201705021601, 32 "from": "userID2" 33 }, 34 "messageID3": { 35 "message": "The relay seems to be malfunctioning.", 36 "timestamp": 201705021703, 37 "from": "userID3" 38 } 39 }, 40 "roomID2": { 41 "messageID4": { 42 "message": "The relay seems to be malfunctioning.", 43 "timestamp": 201705031601, 44 "from": "userID4" 45 }, 46 "messageID5": { 47 "message": "The relay seems to be malfunctioning.", 48 "timestamp": 201705021601, 49 "from": "userID5" 50 }, 51 "messageID6": { 52 "message": "The relay seems to be malfunctioning.", 53 "timestamp": 201705021703, 54 "from": "userID6" 55 } 56 } 57 }, 58 "users" : { 59 "userID1" : { 60 "name": "koki", 61 "regDate": 20170520, 62 "contents" : { 63 "icon" : "xxxx" 64 }, 65 "profileMsg" : "abcde" 66 }, 67 "userID2" : { 68 "name": "kazuko", 69 "regDate": 20190520, 70 "contents" : { 71 "icon" : "yyyy" 72 }, 73 "profileMsg" : "abcde" 74 }, 75 "userID3" : { 76 "name": "masaki", 77 "regDate": 20200520, 78 "contents" : { 79 "icon" : "uuuu" 80 }, 81 "profileMsg" : "abcde" 82 } 83 } 84} 85
回答1件
あなたの回答
tips
プレビュー