Ar Doe Ar Doe - 9 months ago 40
Android Question

Adding IF statement into each array index value in MulitSelectList preference

I'm trying to put an IF statement for each array index value, the value is from MultiSelectList preference. but I'm having problem on doing it, here is my code please help me.

public void displaySelectedDoa(View view) {

mySharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
Set<String> selectionsDoa = mySharedPreferences.getStringSet("selectedDoaKey", null);
String[] selectedDoa = selectionsDoa.toArray(new String[]{});

if (selectedDoa == "0") { // if index number = 0
//do something at here
if (selectedDoa == "1") { // if index nuber = 1
//do here


this is my MultiSelectList from preference fragment

android:title="Select Doa"
android:summary="select your doa"


try this.

CharSequence[] selectedDoa = selectionsDoa.toArray(new String[]{});
    for (int i = 0; i < selectedDoa.length; i++){
        String index = selectedDoa[i].toString();

 if (index.equals("string")){
//do here