How to retrieve the all the Electrician data into a ListView?

If you want to have a listview where each item in the listview contains some or all data of one of the electricians, you first need a datasnapshot of the node 'Electrician'. Also create an object named for example 'elecrician', which has the same data fields as you have in the firebase database. Then use the datasnapshot to create an array of 'electrician' objects similar to the answer of Ryan Pierce. Now that you have an array of electricians with their data, you can show the data that you want to display in a listview.
Besides, maybe it is easier to use time in milliseconds instead of the dates as strings if you want to calculate for example how long an employee has been working there (just easier to work with in my opinion). Also, the field 'JobTitle' might be overkill as the jobtitle is already stated by the node title, e.g. 'Electrician'.
Create list of objects (Electrician) from firebase and then create list view by passing the list of objects in the custom adapter.
Assuming you have a model class for your electrician object named Electrician, to get a list of electrician objects, please use the following code:
DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference electricianRef = rootRef.child("Employee").child("Electrician");
ValueEventListener valueEventListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
List<Electrician> list = new ArrayList<>();
for(DataSnapshot ds : dataSnapshot.getChildren()) {
Electrician electrician = ds.getValue(Electrician.class);
list.add(electrician);
Log.d("TAG", electrician.getLname());
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {}
};
electricianRef.addListenerForSingleValueEvent(valueEventListener);
You can achieve this even simpler, using the String class and getting a list of electrician names for example:
DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference electricianRef = rootRef.child("Employee").child("Electrician");
ValueEventListener valueEventListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
List<String> list = new ArrayList<>();
for(DataSnapshot ds : dataSnapshot.getChildren()) {
String lName = ds.child("Lname").getValue(String.class);
list.add(lName);
Log.d("TAG", lName);
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {}
};
electricianRef.addListenerForSingleValueEvent(valueEventListener);