You must use the SharedPreference between your application. In the Service application, you must write String ch.service.action.FIRST_SERVICE before SharedPreference :
SharedPreference sharedPreferences = getSharedPreferences("any_name", Context.MODE_WORLD_READABLE); SharedPreference.Editor mEditor = sharedPreferences.edit(); mEditor.putString("service_string","ch.service.action.FIRST_SERVICE"); mEditor.commit();
If you want to get the value from another application, you first need to get the Context your service application:
Context mServiceAppContext = createPackageContext("com.example.service_app_package", 0);
You can use mServiceAppContext to get the String value:
SharedPreference sharedPreferences = mServiceAppContext.getSharedPreferences("any_name", Context.MODE_WORLD_READABLE); // Context.MODE_WORLD_READABLE is important, it makes the value readable across other applications sharedPreferences.getString("service_string", /* default value */ "service_string","ch.service.action.FIRST_SERVICE");
The best explanation is given at: http://thedevelopersinfo.com/2009/11/25/getting-sharedpreferences-from-other-application-in-android/
source share