Q:

using shared preferences to store data inside a service?

I have tried using the following code but i am getting errors. getSharedPreferences is undefined. Is there is other way to store string value in Intent services and access it inside an activity.
      SharedPreferences prefs = this.getSharedPreferences(
  "com.example.app", Context.MODE_PRIVATE);

A:

try this :
SharedPreferences prefs = getApplicationContext().getSharedPreferences(
  "com.example.app", Context.MODE_PRIVATE);

instead of 
SharedPreferences prefs = this.getSharedPreferences(
  "com.example.app", Context.MODE_PRIVATE);

