package org.xdevs23.management.config;

public class SharedPreferenceArray {

    public static String getPreferenceString(String[] array) {
        if(array == null)     return "";
        if(array.length == 0) return "";
        StringBuilder sb = new StringBuilder();
        for ( String s : array) {
            String aps;
            if(s == null) return "";
            else aps = s;
            if(s.contains(":")) aps = s.replace(":", "::");
            if(s.contains("|")) aps = aps.replace("|", "||");
            sb.append(aps).append("|:|");
        }
        sb.delete(sb.length() - 3, sb.length());
        return sb.toString();
    }

    public static String[] getStringArray(String preferenceString) {
        if(preferenceString.isEmpty()) return null;
        String[] array = preferenceString.split("([|][:][|])");
        for ( int i = 0; i < array.length; i++ ) {
            String aps = array[i];
            if(aps.contains(":")) aps = aps.replace("::", ":");
            if(aps.contains("|")) aps = aps.replace("||", "|");
            array[i] = aps;
        }
        return array;
    }

}

@@ -745,31 +745,84 @@
 ring
-.isEmpty()) return null
+ == null %7C%7C preferenceString.isEmpty())%0A            return new String%5B%5D %7B%22%22%7D
 ;%0A  

improve safety checks on getStringArray