私だけので、私はリストに保存することができ活動ID1とID2を取得したいです。しかし、私はこれを行うと、最後の行は、私はちょうどActivities={id2=23r90u9329r, id1=jf92jf943jf94j3f9}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
//getting the reference of artists node
databaseCategories = FirebaseDatabase.getInstance().getReference("Categories");
databaseCategories.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
//clear the list
currentCategories.clear();
//iterate through all the node
for(DataSnapshot postsnapshot: dataSnapshot.getChildren()){
//Category j = postsnapshot.getValue(Category.class);
System.out.println("test: " + postsnapshot.getValue());
を得ることができます私はこのような2つのデータベース参照を作成しようとしたが、それはNULLを返していますどのように
{Category 1={name=joy, Sprint={Activities={id2=23r90u9329r,
id1=jf92jf943jf94j3f9}, startingDate =08092017, sprintOverallScore=1,
Ending Date=08092017, Number of Weeks=2}}
全体のオブジェクト参照を返します。
DatabaseReference databaseCategories, databaseCategories2;
....
databaseCategories.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
//clear the list
currentCategories.clear();
//iterate through all the node
for(DataSnapshot postsnapshot: dataSnapshot.getChildren()){
String g = postsnapshot.getKey(); //get the id
databaseCategories2 = FirebaseDatabase.getInstance().getReference("CategoryNew").child(g+"").child("Category 1").child("Sprint").child("Activities");
databaseCategories2.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
System.out.println("test new: " + dataSnapshot.getValue()); //returning NULL
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
あなたの質問にJSONツリーの画像が含まれています。実際のJSONをテキストとして置き換えてください。このテキストは[Firebaseデータベースコンソール](https://console.firebase.google.com/project/_/database/data/)の[Export JSON]リンクをクリックすることで簡単に取得できます。 。 JSONをテキストとして検索可能にすることで、実際のデータを使ってテストしたり、答えに使用したりすることができます。一般的には、これは良いことです。 –