I am explaining the scenario using the following image:
from that, I would like to get the name and number of nodes. From this image, I would like to get nodes' names (Company, GovDepartment, and students) and their count number. for example, there are 3 numbers of nodes are present which stored as Company, GovDepartment, and students, how could I get it? how could I make it complete? the following android code needs to complete:
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
public class MainActivity extends AppCompatActivity {
EditText t1,t2,t3,t4;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void process(View v){
dataholder obj = new dataholder(name,course,duration);
FirebaseDatabase db = FirebaseDatabase.getInstance();
DatabaseReference node = db.getReference();
}
}
here the method called by a OnClick button as:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="process"
android:text="Read and count the nodes"
android:textSize="25dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.491"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.66"
tools:ignore="MissingConstraints,OnClick" />
you may use the another layout to show the fetched data from the firebase database.