Here you can find the source of savePreference(String key, Object value)
public static void savePreference(String key, Object value)
//package com.java2s; import java.util.prefs.Preferences; public class Main { private static Preferences prefs = null; public static void savePreference(String key, Object value) { if (value instanceof String) { prefs.put(key, (String) value); } else if (value instanceof Boolean) { prefs.putBoolean(key, (Boolean) value); } else if (value instanceof Integer) { prefs.putInt(key, (Integer) value); }//from w ww . j a va 2 s.c om } }