I have two differents application in Android. I need send data from one to the other one. The first is a Activity where i put in this data value in sharedpreferences file:
SharedPreferences selector;
selector = getSharedPreferences("tecnologia", Context.MODE_WORLD_READABLE);
Editor editor = selector.edit();
select = (RadioButton) findViewById(opciones.getCheckedRadioButtonId());
switch (select.getId()) {
case R.id.radio0:
editor.putString("opcion", "US");
editor.commit();
break;
case R.id.radio1:
editor.putString("opcion", "UWB");
editor.commit();
break;
}
Intent i = new Intent(this, ServiceConexion.class);
startActivity(i);
finish();
In the second Activity wich i launch i check this file and is correct. Then i call a remote servie.
In this second service (second project) i read this file:
try {
Context con = createPackageContext(
"org.gradiant.sistole.locdisplay",
0);
SharedPreferences configuracion;
configuracion = con.getSharedPreferences("tecnologia",
MODE_PRIVATE);
select = configuracion.getString("opcion", "00");
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
But not always has the correct value. Why?