Is my program I want to save and read certain configuration data but for some reason they are not saved or can not read correctly, could someone tell me what my error is?
Code to save:
int mConfigBaudRate = 115200;
int mConfigDataBit = 8;
int mConfigBitStop = 1;
int mConfigParity = 0;
String mFlagConexion = "";
public void guardarConfigSerialPortShareref(){
SharedPreferences myPreferences = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
SharedPreferences.Editor editor = myPreferences.edit();
editor.putInt("mconfigbaudratex", mConfigBaudRate);
editor.putInt("mconfigdatabitx", mConfigDataBit);
editor.putInt("mconfigbitstopx", mConfigBitStop);
editor.putInt("mconfigparityx", mConfigParity);
editor.putString("mFlagConexionx", "OK");
editor.commit();
}
Code to read:
public void leerConfigSerialPortShareref() {
SharedPreferences myPreferences = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
mConfigBaudRate = myPreferences.getInt("mconfigbaudratex", 0);
mConfigDataBit = myPreferences.getInt("mconfigdatabitx", 0);
mConfigBitStop = myPreferences.getInt("mconfigbitstopx", 0);
mConfigParity = myPreferences.getInt("mconfigparityx", 0);
mFlagConexion = myPreferences.getString("mFlagConexionx", "");
}