Example usage for android.content SharedPreferences getInt

List of usage examples for android.content SharedPreferences getInt

Introduction

In this page you can find the example usage for android.content SharedPreferences getInt.

Prototype

int getInt(String key, int defValue);

Source Link

Document

Retrieve an int value from the preferences.

Usage

From source file:com.cettco.buycar.activity.BargainActivity.java

private void getArray() {
    Resources res = getResources();
    String[] tmp = res.getStringArray(R.array.getcarTime_array);
    getcarTimeList = new ArrayList<String>(Arrays.asList(tmp));
    // ArrayList<String> aa= (ArrayList<String>) Arrays.asList(tmp);
    tmp = res.getStringArray(R.array.loan_array);
    loanList = new ArrayList<String>(Arrays.asList(tmp));
    tmp = res.getStringArray(R.array.location_array);
    locationList = new ArrayList<String>(Arrays.asList(tmp));
    SharedPreferences settings = getSharedPreferences("city_selection", 0);
    int selection = settings.getInt("city", 0);
    if (selection == 0)
        locationList.set(0, locationList.get(0) + "()");
    else if (selection == 1)
        locationList.set(0, locationList.get(0) + "()");
    tmp = res.getStringArray(R.array.plate_array);
    plateList = new ArrayList<String>(Arrays.asList(tmp));
}

From source file:com.imobilize.blogposts.fragments.SubscribeFragment.java

private String getRegistrationId(Context context) {
    final SharedPreferences prefs = getGcmPreferences(context);
    String registrationId = prefs.getString(Constants.PROPERTY_REG_ID, "");

    if (registrationId.equals("")) {
        Log.i(Constants.TAG, "Registration not found.");
        return "";
    }// w ww  .  java 2 s  .c om

    int registeredVersion = prefs.getInt(Constants.PROPERTY_APP_VERSION, Integer.MIN_VALUE);
    int currentVersion = getAppVersion(context);
    if (registeredVersion != currentVersion) {
        Log.i(Constants.TAG, "App version changed.");
        return "";
    }
    return registrationId;
}

From source file:com.allthingsgeek.celljoust.MainActivity.java

private void loadPrefs() {
    // Restore preferences
    SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
    putUrl = settings.getString("REMOTE_EYES_PUT_URL", "http://example.com:8080/cellserv");
    noise.setOffsetPulsePercent(settings.getInt("servo1Percent", 50), 0);
    noise.setOffsetPulsePercent(settings.getInt("servo2Percent", 50), 1);
    noise.setOffsetPulsePercent(settings.getInt("servo3Percent", 50), 2);
    noise.setOffsetPulsePercent(settings.getInt("servo4Percent", 50), 3);
    mover.setOffset(settings.getInt("wheelOffset", 0));
    RobotStateHandler.ROBOT_ID = settings.getString("ROBOT_ID", RobotStateHandler.ROBOT_ID);

}

From source file:ca.mimic.apphangar.Settings.java

public static List<AppsRowItem> createAppTasks() {
    db = TasksDataSource.getInstance(mContext);
    db.open();/* w w w. ja v a  2s .  c  o m*/
    int highestSeconds = db.getHighestSeconds();
    List<TasksModel> tasks = db.getAllTasks();

    List<AppsRowItem> appTasks = new ArrayList<AppsRowItem>();

    for (TasksModel task : tasks) {
        try {
            try {
                ComponentName.unflattenFromString(task.getPackageName() + "/" + task.getClassName());
            } catch (Exception e) {
                Tools.HangarLog("Could not find Application info for [" + task.getName() + "]");
                db.deleteTask(task);
                continue;
            }
            if (new Tools().cachedImageResolveInfo(mContext, task.getPackageName()) != null)
                appTasks.add(createAppRowItem(task, highestSeconds));
        } catch (Exception e) {
            Tools.HangarLog("could not add taskList item " + e);
        }

        SharedPreferences prefs2 = prefs.prefsGet();
        Collections.sort(appTasks,
                new Tools.AppRowComparator(prefs2.getInt(APPLIST_TOP_PREFERENCE, APPLIST_TOP_DEFAULT),
                        prefs2.getInt(APPLIST_SORT_PREFERENCE, APPLIST_SORT_DEFAULT)));

    }
    db.close();
    return appTasks;
}

From source file:com.attentec.Status.java

/**
 * Load Status from preferences./*from  w  w w  . j  a v  a 2s.c om*/
 * @param sp SharedPreferences to load from
 * @return true on success
 */
public final boolean load(final SharedPreferences sp) {
    if (sp == null) {
        Log.e(TAG, "SharedPreferences is null in load.");
        return false;
    }
    //Load the status from preferences
    mCustomMessage = sp.getString(STATUS_CUSTOM_MESSAGE, "");
    mStatus = sp.getInt(STATUS, Status.STATUS_ONLINE);
    notifyObservers();
    return true;
}

From source file:com.svpino.longhorn.MarketCollectorService.java

@Override
protected void onHandleIntent(Intent intent) {
    SharedPreferences sharedPreferences = getSharedPreferences(Constants.PREFERENCES, Context.MODE_PRIVATE);
    long lastUpdate = sharedPreferences.getLong(Constants.PREFERENCE_COLLECTOR_LAST_UPDATE, 0);
    boolean retrying = sharedPreferences.getBoolean(Constants.PREFERENCE_COLLECTOR_RETRYING, false);
    int retries = sharedPreferences.getInt(Constants.PREFERENCE_COLLECTOR_RETRIES, 0);
    boolean wereWeWaitingForConnectivity = sharedPreferences
            .getBoolean(Constants.PREFERENCE_STATUS_WAITING_FOR_CONNECTIVITY, false);

    boolean isGlobalCollection = intent.getExtras() == null
            || (intent.getExtras() != null && !intent.getExtras().containsKey(EXTRA_TICKER));

    if (wereWeWaitingForConnectivity) {
        Editor editor = sharedPreferences.edit();
        editor.putBoolean(Constants.PREFERENCE_STATUS_WAITING_FOR_CONNECTIVITY, false);
        editor.commit();/*from w  ww  .jav  a2s. co  m*/
    }

    if (retrying && isGlobalCollection) {
        Editor editor = sharedPreferences.edit();
        editor.putBoolean(Constants.PREFERENCE_COLLECTOR_RETRYING, false);
        editor.putInt(Constants.PREFERENCE_COLLECTOR_RETRIES, 0);
        editor.commit();

        ((AlarmManager) getSystemService(Context.ALARM_SERVICE))
                .cancel(Extensions.createPendingIntent(this, Constants.SCHEDULE_RETRY));
    }

    long currentTime = System.currentTimeMillis();
    if (retrying || wereWeWaitingForConnectivity || !isGlobalCollection
            || (isGlobalCollection && currentTime - lastUpdate > Constants.COLLECTOR_MIN_REFRESH_INTERVAL)) {
        String[] tickers = null;

        if (isGlobalCollection) {
            Log.d(LOG_TAG, "Executing global market information collection...");
            tickers = DataProvider.getStockDataTickers(this);
        } else {
            String ticker = intent.getExtras().containsKey(EXTRA_TICKER)
                    ? intent.getExtras().getString(EXTRA_TICKER)
                    : null;

            Log.d(LOG_TAG, "Executing market information collection for ticker " + ticker + ".");

            tickers = new String[] { ticker };
        }

        try {
            collect(tickers);

            if (isGlobalCollection) {
                Editor editor = sharedPreferences.edit();
                editor.putLong(Constants.PREFERENCE_COLLECTOR_LAST_UPDATE, System.currentTimeMillis());
                editor.commit();
            }

            DataProvider.notifyDataCollectionIsFinished(this, tickers);

            Log.d(LOG_TAG, "Market information collection was successfully completed");
        } catch (Exception e) {
            Log.e(LOG_TAG, "Market information collection failed.", e);

            if (Extensions.areWeOnline(this)) {
                Log.d(LOG_TAG, "Scheduling an alarm for retrying a global market information collection...");

                retries++;

                Editor editor = sharedPreferences.edit();
                editor.putBoolean(Constants.PREFERENCE_COLLECTOR_RETRYING, true);
                editor.putInt(Constants.PREFERENCE_COLLECTOR_RETRIES, retries);
                editor.commit();

                long interval = Constants.COLLECTOR_MIN_RETRY_INTERVAL * retries;
                if (interval > Constants.COLLECTOR_MAX_REFRESH_INTERVAL) {
                    interval = Constants.COLLECTOR_MAX_REFRESH_INTERVAL;
                }

                ((AlarmManager) getSystemService(Context.ALARM_SERVICE)).set(AlarmManager.RTC,
                        System.currentTimeMillis() + interval,
                        Extensions.createPendingIntent(this, Constants.SCHEDULE_RETRY));
            } else {
                Log.d(LOG_TAG,
                        "It appears that we are not online, so let's start listening for connectivity updates.");

                Editor editor = sharedPreferences.edit();
                editor.putBoolean(Constants.PREFERENCE_STATUS_WAITING_FOR_CONNECTIVITY, true);
                editor.commit();

                ComponentName componentName = new ComponentName(this, ConnectivityBroadcastReceiver.class);
                getPackageManager().setComponentEnabledSetting(componentName,
                        PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
            }
        }
    } else if (isGlobalCollection && currentTime - lastUpdate <= Constants.COLLECTOR_MIN_REFRESH_INTERVAL) {
        Log.d(LOG_TAG, "Global market information collection will be skipped since it was performed less than "
                + (Constants.COLLECTOR_MIN_REFRESH_INTERVAL / 60 / 1000) + " minutes ago.");
    }

    stopSelf();
}

From source file:de.tu_berlin.snet.probe.FacebookProbe.java

private void fetchFacebook() {
    try {/*w  w  w  .  j  a  va  2s.  co m*/
        SharedPreferences prefs = getContext().getSharedPreferences("default", Context.MODE_MULTI_PROCESS);
        Session session = Session.getActiveSession();
        List<Request> requests = new ArrayList<Request>();

        if (session == null) {
            Log.d(TAG, "Facebook Probe not activated.");
            return;
        }

        // default is Tue, 01 Jan 2008 00:00:00 GMT
        int since = prefs.getInt("facebook.since", 1199145600);
        int until = (int) (System.currentTimeMillis() / 1000);

        Bundle params = new Bundle();
        params.putInt("since", since);
        params.putInt("until", until);
        params.putInt("limit", 5000);

        for (final String requestId : REQUEST_IDS) {
            requests.add(new Request(session, requestId, params, null, new Request.Callback() {

                public void onCompleted(Response response) {
                    GraphObject graphObject = response.getGraphObject();
                    FacebookRequestError error = response.getError();

                    if (graphObject != null) {
                        JSONObject orig = graphObject.getInnerJSONObject();
                        JsonObject data = new JsonObject();

                        anonymizeData(orig);
                        data.addProperty(response.getRequest().getGraphPath(), orig.toString());
                        sendData(data);

                    } else if (error != null) {
                        Log.e(TAG, "Error: " + error.getErrorMessage());
                    }
                }

                private Set<String> sensitiveSet = new HashSet<String>(Arrays.asList(SENSITIVE));

                private void anonymizeData(Object o) {
                    try {
                        if (o instanceof JSONObject) {
                            JSONObject obj = (JSONObject) o;

                            // not needed, may contain sensitive data
                            obj.remove("paging");
                            obj.remove("actions");

                            for (Iterator<?> iter = obj.keys(); iter.hasNext();) {
                                String key = (String) iter.next();
                                Object val = obj.get(key);

                                if (!(val instanceof String))
                                    anonymizeData(val);

                                if (sensitiveSet.contains(key))
                                    obj.put(key, sensitiveData((String) val));
                            }
                        } else if (o instanceof JSONArray) {
                            JSONArray arr = (JSONArray) o;

                            for (int i = 0; i < arr.length(); i++)
                                anonymizeData(arr.get(i));
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            }));
        }
        boolean error = false;
        for (Response r : Request.executeBatchAndWait(requests)) {
            if (r.getError() != null)
                error = true;
        }
        if (!error)
            prefs.edit().putInt("facebook.since", until + 1).commit();

    } catch (Exception e) {
        e.printStackTrace();
    }
    stop();
}

From source file:com.rti.motorcontrolpub.MotorControlMainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_motor_control_main);

    /* Uncomment this to turn on additional logging */
    /*//from  www  .j a  va2  s. c  o m
     * Logger.get_instance().set_verbosity_by_category(
     * LogCategory.NDDS_CONFIG_LOG_CATEGORY_API,
     * LogVerbosity.NDDS_CONFIG_LOG_VERBOSITY_STATUS_ALL);
     */
    // Log.i(TAG, "calling publisherMain");
    // Starting DDS subscriber as separate threaded task...
    if (MotorControlPublisher.Pub_sub_create_count == 1) {
        ExecutorService service = Executors.newFixedThreadPool(4);
        service.submit(new Runnable() {
            @Override
            public void run() {
                String[] args = { "0" };// {"0", "0"};
                MotorControlPublisher.main(args);
            }
        });
        MotorControlPublisher.Pub_sub_create_count = 0;

    }

    final Button StartBtn = (Button) findViewById(R.id.btnSubmit);
    StartBtn.setOnClickListener(new OnClickListener() {
        final Spinner spinner1 = (Spinner) findViewById(R.id.spinner1);
        final Spinner spinner2 = (Spinner) findViewById(R.id.spinner2);
        final Spinner spinner3 = (Spinner) findViewById(R.id.spinner3);
        final Spinner spinner4 = (Spinner) findViewById(R.id.spinner4);

        // Do click handling here
        public void onClick(View view) {
            MotorControlPublisher.flagBtn = true;
            spinner1.setEnabled(true);
            spinner2.setEnabled(true);
            spinner3.setEnabled(true);
            spinner4.setEnabled(true);

            if (spinner1.getSelectedItem().toString().equals("Green")) {
                MotorControlMainActivity.mMotor_id = "1";
            }
            if (spinner1.getSelectedItem().toString().equals("Yellow")) {
                MotorControlMainActivity.mMotor_id = "2";
            }
            if (spinner1.getSelectedItem().toString().equals("Both")) {
                MotorControlMainActivity.mMotor_id = "3";
            }

            MotorControlMainActivity.mTime_sec = Integer.valueOf(spinner2.getSelectedItem().toString());

            if (spinner3.getSelectedItem().toString().equals("Clock")) {
                MotorControlMainActivity.mDirection = "0";
            }
            if (spinner3.getSelectedItem().toString().equals("Anti")) {
                MotorControlMainActivity.mDirection = "1";
            }
            if (spinner3.getSelectedItem().toString().equals("Invrt")) {
                MotorControlMainActivity.mDirection = "2";
            }
            if (spinner3.getSelectedItem().toString().equals("Outvt")) {
                MotorControlMainActivity.mDirection = "3";
            }

            if (spinner4.getSelectedItem().toString().equals("Fastest")) {
                MotorControlMainActivity.mSpeed = 1;
            }
            if (spinner4.getSelectedItem().toString().equals("Faster")) {
                MotorControlMainActivity.mSpeed = 2;
            }
            if (spinner4.getSelectedItem().toString().equals("Fast")) {
                MotorControlMainActivity.mSpeed = 3;
            }
            if (spinner4.getSelectedItem().toString().equals("Slow")) {
                MotorControlMainActivity.mSpeed = 4;
            }
            if (spinner4.getSelectedItem().toString().equals("Slower")) {
                MotorControlMainActivity.mSpeed = 6;
            }
            if (spinner4.getSelectedItem().toString().equals("Slowest")) {
                MotorControlMainActivity.mSpeed = 8;
            }

            System.out.println("MotorControlPublisher.mMotor_id " + MotorControlMainActivity.mMotor_id);
            System.out.println("MotorControlPublisher.mTime_sec " + MotorControlMainActivity.mTime_sec);
            System.out.println("MotorControlPublisher.mDirection" + MotorControlMainActivity.mDirection);
            System.out.println("otorControlPublisher.mSpeed" + MotorControlMainActivity.mSpeed);

            // code for Web DDS HTTP POST //

            final DefaultHttpClient httpClient = new DefaultHttpClient();
            httpClient.getParams().setParameter(ClientPNames.HANDLE_REDIRECTS, Boolean.FALSE);
            httpClient.getParams().getParameter("http.protocol.version");

            Thread t = new Thread(new Runnable() {
                @Override
                public void run() {
                    // replace with your url
                    StringEntity se = null;
                    httppost = new HttpPost(
                            "http://87.82.193.136:8080/dds/rest1/applications/LED_Demo/participants/LEDs/publishers/MyPublisher/datawriters/MyMCWriter");
                    try {
                        se = new StringEntity("<MotorControl><motor_id>" + MotorControlMainActivity.mMotor_id
                                + "</motor_id><time_sec>" + MotorControlMainActivity.mTime_sec
                                + "</time_sec><direction>" + MotorControlMainActivity.mDirection
                                + "</direction><speed>" + MotorControlMainActivity.mSpeed
                                + "</speed><action>0</action></MotorControl>", "UTF-8");
                    } catch (UnsupportedEncodingException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    //System.out.println("POST: " + se);
                    se.setContentType("application/webdds+xml");
                    httppost.addHeader("Cache-Control", "no-cache");

                    httppost.setEntity(se);
                    try {
                        httpClient.execute(httppost);
                    }

                    catch (ClientProtocolException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                }
            });
            t.start();

            final TextView mTextField = (TextView) findViewById(R.id.textView4);

            new CountDownTimer(MotorControlMainActivity.mTime_sec * 1000, 1000) {

                public void onTick(long millisUntilFinished) {
                    StartBtn.setEnabled(false);
                    spinner1.setEnabled(false);
                    spinner2.setEnabled(false);
                    spinner3.setEnabled(false);
                    spinner4.setEnabled(false);

                    mTextField.setText("Finishing in: " + millisUntilFinished / 1000 + " secs");
                }

                public void onFinish() {
                    // MotorControlPublisher.flagBtn = false;
                    mTextField.setText("               ");
                    StartBtn.setEnabled(true);
                    spinner1.setEnabled(true);
                    spinner2.setEnabled(true);
                    spinner3.setEnabled(true);
                    spinner4.setEnabled(true);

                    if (spinner1.getSelectedItem().toString().equals("Green")) {
                        MotorControlMainActivity.mMotor_id = "1";
                    }
                    if (spinner1.getSelectedItem().toString().equals("Yellow")) {
                        MotorControlMainActivity.mMotor_id = "2";
                    }
                    if (spinner1.getSelectedItem().toString().equals("Both")) {
                        MotorControlMainActivity.mMotor_id = "3";
                    }

                    MotorControlMainActivity.mTime_sec = Integer.valueOf(spinner2.getSelectedItem().toString());

                    if (spinner3.getSelectedItem().toString().equals("Clock")) {
                        MotorControlMainActivity.mDirection = "0";
                    }

                    if (spinner3.getSelectedItem().toString().equals("Anti")) {
                        MotorControlMainActivity.mDirection = "1";
                    }

                    if (spinner3.getSelectedItem().toString().equals("Invrt")) {
                        MotorControlMainActivity.mDirection = "2";
                    }

                    if (spinner3.getSelectedItem().toString().equals("Outvt")) {
                        MotorControlMainActivity.mDirection = "3";
                    }

                    if (spinner4.getSelectedItem().toString().equals("Fastest")) {
                        MotorControlMainActivity.mSpeed = 1;
                    }
                    if (spinner4.getSelectedItem().toString().equals("Faster")) {
                        MotorControlMainActivity.mSpeed = 2;
                    }
                    if (spinner4.getSelectedItem().toString().equals("Fast")) {
                        MotorControlMainActivity.mSpeed = 3;
                    }
                    if (spinner4.getSelectedItem().toString().equals("Slow")) {
                        MotorControlMainActivity.mSpeed = 4;
                    }
                    if (spinner4.getSelectedItem().toString().equals("Slower")) {
                        MotorControlMainActivity.mSpeed = 6;
                    }
                    if (spinner4.getSelectedItem().toString().equals("Slowest")) {
                        MotorControlMainActivity.mSpeed = 8;
                    }

                }
            }.start();

        }
    });

    /* Integration code for WebCam */

    SharedPreferences preferences = getSharedPreferences("SAVED_VALUES", MODE_PRIVATE);
    width = preferences.getInt("width", width);
    height = preferences.getInt("height", height);
    ip_ad1 = preferences.getInt("ip_ad1", ip_ad1);
    ip_ad2 = preferences.getInt("ip_ad2", ip_ad2);
    ip_ad3 = preferences.getInt("ip_ad3", ip_ad3);
    ip_ad4 = preferences.getInt("ip_ad4", ip_ad4);
    ip_port = preferences.getInt("ip_port", ip_port);
    ip_command = preferences.getString("ip_command", ip_command);

    StringBuilder sb = new StringBuilder();
    String s_http = "http://";
    String s_dot = ".";
    String s_colon = ":";
    String s_slash = "/";
    sb.append(s_http);
    sb.append(ip_ad1);
    sb.append(s_dot);
    sb.append(ip_ad2);
    sb.append(s_dot);
    sb.append(ip_ad3);
    sb.append(s_dot);
    sb.append(ip_ad4);
    sb.append(s_colon);
    sb.append(ip_port);
    sb.append(s_slash);
    sb.append(ip_command);
    URL = new String(sb);

    mv = (MjpegView) findViewById(R.id.mv);
    if (mv != null) {
        mv.setResolution(width, height);
    }

    // setTitle(R.string.title_connecting);
    /* (e.g. x.new A() where x is an instance of MjpegActivity). */
    MjpegActivity x = new MjpegActivity();

    x.new DoRead().execute(URL);
}

From source file:com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushIntentService.java

protected void dismissNotification(String nid) {
    SharedPreferences sharedPreferences = getApplicationContext().getSharedPreferences(MFPPush.PREFS_NAME,
            Context.MODE_PRIVATE);
    int countOfStoredMessages = sharedPreferences.getInt(MFPPush.PREFS_NOTIFICATION_COUNT, 0);

    if (countOfStoredMessages > 0) {
        for (int index = 1; index <= countOfStoredMessages; index++) {

            String key = MFPPush.PREFS_NOTIFICATION_MSG + index;
            try {
                String msg = sharedPreferences.getString(key, null);
                if (msg != null) {
                    JSONObject messageObject = new JSONObject(msg);
                    if (messageObject != null && !messageObject.isNull(NID)) {
                        String id = messageObject.getString(NID);
                        if (id != null && id.equals(nid)) {
                            MFPPushUtils.removeContentFromSharedPreferences(sharedPreferences, key);
                            MFPPushUtils.storeContentInSharedPreferences(sharedPreferences,
                                    MFPPush.PREFS_NOTIFICATION_COUNT, countOfStoredMessages - 1);
                            NotificationManager mNotificationManager = (NotificationManager) this
                                    .getSystemService(Context.NOTIFICATION_SERVICE);
                            mNotificationManager.cancel(messageObject.getInt(NOTIFICATIONID));
                        }/*from w w  w  . j a v a  2s  .c  o m*/
                    }
                }
            } catch (JSONException e) {
                logger.error("MFPPushIntentService: dismissNotification() - Failed to dismiss notification.");
            }
        }
    }
}

From source file:com.lewen.listener.vlc.Util.java

public static void updateLibVlcSettings(SharedPreferences pref) {
    LibVLC instance = LibVLC.getExistingInstance();
    if (instance == null)
        return;//w w  w  .ja v  a2s  .  co m

    instance.setIomx(pref.getBoolean("enable_iomx", false));
    instance.setSubtitlesEncoding(pref.getString("subtitles_text_encoding", ""));
    instance.setTimeStretching(pref.getBoolean("enable_time_stretching_audio", false));
    instance.setFrameSkip(pref.getBoolean("enable_frame_skip", false));
    instance.setChroma(pref.getString("chroma_format", ""));
    instance.setVerboseMode(pref.getBoolean("enable_verbose_mode", true));

    if (pref.getBoolean("equalizer_enabled", false))
        instance.setEqualizer(getFloatArray(pref, "equalizer_values"));

    int aout;
    try {
        aout = Integer.parseInt(pref.getString("aout", "-1"));
    } catch (NumberFormatException nfe) {
        aout = -1;
    }
    int vout;
    try {
        vout = Integer.parseInt(pref.getString("vout", "-1"));
    } catch (NumberFormatException nfe) {
        vout = -1;
    }
    int deblocking;
    try {
        deblocking = Integer.parseInt(pref.getString("deblocking", "-1"));
    } catch (NumberFormatException nfe) {
        deblocking = -1;
    }
    int networkCaching = pref.getInt("network_caching_value", 0);
    if (networkCaching > 60000)
        networkCaching = 60000;
    else if (networkCaching < 0)
        networkCaching = 0;
    instance.setAout(aout);
    instance.setVout(vout);
    instance.setDeblocking(deblocking);
    instance.setNetworkCaching(networkCaching);
}