title: Shared Preferences Not Working in BroadcastReceiver
body: <p>I have an app that uses sharedpreferences.  It works fine in Activities.  But, the same SharedPreference methods won't work in a BroadcastReceiver or Service.</p>
  
  <p>Example Activity works fine:</p>
  
  <pre><code>import android.content.SharedPreferences;
  
  public class SetTelco extends Activity implements OnClickListener, OnItemSelectedListener {
  
      public static final String Telco="Telco";
      public static String phoneNum;
  
    public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int pos, long id) {
          // An item was selected. You can retrieve the selected item using
          //parent.getItemAtPosition(pos).toString();
          String phoneNum = getResources().getStringArray(R.array.country_short_codes)[parent.getSelectedItemPosition()];
          SharedPreferences telco=getSharedPreferences(Telco,Context.MODE_WORLD_READABLE);
          SharedPreferences.Editor telcoEdit=telco.edit();
          telcoEdit.clear();
          telcoEdit.putString(Telco, phoneNum);
          //Toast.makeText(getApplicationContext(), phoneNum, 5000).show();
          telcoEdit.commit();
      }
  }
  </code></pre>
  
  <p>=========================</p>
  
  <p>Example BroadcastReceiver:</p>
  
  <p>Eclipse gives me an error:
  Multiple markers at this line
      - The field Context.MODE_WORLD_READABLE is deprecated
      - The method getSharedPreferences(String, int) is undefined for the type SetAlarms</p>
  
  <pre><code>import android.content.SharedPreferences;
  
  public class SetAlarms extends BroadcastReceiver {
      public void onReceive(Context context, Intent intent) {   
          SharedPreferences telco=getSharedPreferences(Telco,Context.MODE_WORLD_READABLE);
          String phoneNum="Empty";
          phoneNum=telco.getString(Telco,"Empty");
                  .
                  .
                  .
                  sms.sendTextMessage(phoneNum, null, sendMsg, null, null);
      }
  }
  </code></pre>
  
  <p>Can't figure out what the difference is.  According to the docs, SharedPreferences should work in all components, Activities &amp; Services.</p>
  
  <p>Any help appreciated.</p>