I'm working on project in android. my situation i stored list value in firebase Realtime database and then the List value and my given value is equal the checkbox will be checked.
For example: the List holding 36,40, 44.then my given value is equals to that List value then the equivalent checkbox will be checked.
My code is
checkcheck=FirebaseDatabase.getInstance().getReference().child("Products").child(newprokey);
checkcheck.child("size").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
final List<String> areas = new ArrayList<String>();
for (DataSnapshot areaSnapshot : dataSnapshot.getChildren()) {
String areaName = areaSnapshot.child("Value").getValue(String.class);
areas.add(areaName);
}
String[] check = areas.toArray(new String[areas.size()]);
for (int i= 0;i<check.length;i++)
{
if (check[i] == "36")
{
jS36.setChecked(true);
}
if (check[i] == "38")
{
jM38.setChecked(true);
}
if (check[i] == "40")
{
jL40.setChecked(true);
}
if (check[i] == "42")
{
jXl42.setChecked(true);
}
if (check[i] == "44")
{
jXxl44.setChecked(true);
}
if (check[i] == "46")
{
jXXXl46.setChecked(true);
}
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
i try this code. it's not working, give me solution.