Code example for SharedPreferences.Editor: Saving app preferences

Methods: commit, putInt, putString

            int existingHash = appSettings.getInt("webCertHash", 0);
            if (existingHash == 0) {
                Log.i("MobileOrg", "Storing new certificate");
                edit.putInt("webCertHash", hash);
                edit.putString("webCertDescr", description);
                return true; 
            else if (existingHash != hash) {
                Log.i("MobileOrg", "Conflicting Certificate Hash");
                edit.putInt("webConflictHash", hash);
                edit.putString("webConflictHashDesc", description);
                return true; 
                //WARNING: NOTE: This disables the requirement to validate the certificate. 
                //               a better way is needed for those certs whose hash changes 
                //               all the time 
                //return false; 
            Log.i("MobileOrg", "Certificates match");
Connect your IDE to all the code out there  Get Codota for Java