2

I am new to android programming. I have saved my data insharedPreference and get the data back and store as following

        Set <String> set = sharedPref.getStringSet(dayName, null);

This Set <String> set got 3 array stored in a row arrayOne, arrayTwo, arrayThree with a TAG. Is there any way to convert it into array and save individually.

Thanks for the help.

2 Answers 2

6

try this example

Set<String> set = new HashSet<String>();
set.add("object 1");
set.add("object 2");
set.add("object 3");
set.add("object 4");

String[] array = null;

array = set.toArray(new String[set.size()]);

for(String item:array){
    System.out.println(item);
}

Anohter related question

Set javadic

Sign up to request clarification or add additional context in comments.

Comments

1

You can convert Set<String> into Array of String as follows...

Set <String> set = sharedPref.getStringSet(dayName, null);
List<String> list = new ArrayList<String>(set);
String[] objects = list.toArray();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.