unable to unlink data, no such file or directory exist error on retrieving shared preference
<p>i have this problem for some time now and i don't know what to do anymore. i am trying to get the values back from a shared Preference, but i keep getting this unable to unlink data error. i don't know what to do anymore, the only explanation i have seen so far for this error is that it is trying to access a file from a local directory that's not there. it seems it is trivial, but i can't get any values back from the shared preferences stored. </p>

<p>Any idea on what might be the problem? </p>

<p>by the way, i am trying to use it in an appWidget, in case that helps. Thank you</p>

<p>edit: here is the code that saves the preference:</p>

<pre><code>public class WeatherForecastConfigure extends Activity implements OnClickListener {

    private int appWidgetId;  
    SharedPreferences prefs;

    EditText cityText;
    Button save;
    Spinner update;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        prefs = getSharedPreferences("myWeatherPrefs", 0);

         Intent launchIntent = getIntent();
         Bundle extras = launchIntent.getExtras();
         appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID,
                         AppWidgetManager.INVALID_APPWIDGET_ID);

         setContentView(R.layout.weather_view_configuration);

         cityText = (EditText)findViewById(R.id.editCity_id);
        //chk_celsius = (CheckBox) findViewById(R.id.celsius_toggle_id);
         save = (Button)findViewById(R.id.SaveButton);
         update =(Spinner)findViewById(R.id.spinner_update_id);

        cityText.setOnClickListener(this);
        save.setOnClickListener(this);


    }

    @Override
    public void onClick(View v) {
        int selection = v.getId();

        switch(selection){
        case R.id.SaveButton:
               savePreferences();

               Intent resultValue = new Intent();
               resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,appWidgetId);
               setResult(RESULT_OK, resultValue);
               finish();

       }

    }

    private void savePreferences() {
        prefs = getSharedPreferences("myWeatherPrefs", 0);

        String city = cityText.getText().toString();

        Editor editor = prefs.edit();
        editor.putString("citySet" + appWidgetId, city);
        editor.commit();
    }
</code></pre>

<p>and here is where am trying to access it in a service:</p>

<pre><code>public class weatherForecast extends Service implements Runnable  {

     public static final String TAG = "WeatherForecastService";
     public static final String UPDATE = "update";
     int appWidgetID = AppWidgetManager.INVALID_APPWIDGET_ID;

     String city;
     Boolean chk_celsius;
     SharedPreferences prefs;

    @Override
    public IBinder onBind(Intent arg0) {
        // TODO Auto-generated method stub
        return null;
    }

    /*public void onCreate(){
        Log.d(TAG, "onCreate");
    }*/

    public void onStart(Intent intent, int startId){
        URL url;
        Log.d(TAG,"onStart");

           prefs = getApplicationContext().getSharedPreferences("myWeatherPrefs", 0);
            city = prefs.getString("citySet" + appWidgetID,"nothing");

            Log.i(TAG, "service city is " + city);

        Bundle extra = intent.getExtras();
           if(extra != null){
               appWidgetID = extra.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
               Log.v("WIDGET_TAG_ID", "appWidgetId = " + appWidgetID);
           }

           RemoteViews remoteView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.weather_appwidget);
           AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getApplicationContext());
</code></pre>

<p>my widget class:</p>

<pre><code>public class WeatherWidgetProvider extends AppWidgetProvider{

    SharedPreferences prefs;
    @Override
        public void onEnabled(Context context){

    }

    public void updateForecast(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds){
    }

        @Override
     public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds){
            for (int appWidgetId : appWidgetIds) {
                RemoteViews remoteView = new RemoteViews(context.getPackageName(),
                                R.layout.weather_appwidget);
                appWidgetManager.updateAppWidget(appWidgetId, remoteView);
        }
                 super.onUpdate(context, appWidgetManager, appWidgetIds);
        }

    @Override
    public void onReceive(Context context, Intent intent){


        Log.d("onReceive", "gets called first");
        final String action = intent.getAction();
        if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(action)) {
            Bundle extras = intent.getExtras();
            final int appWidgetId = extras.getInt
    (AppWidgetManager.EXTRA_APPWIDGET_ID,
                    AppWidgetManager.INVALID_APPWIDGET_ID);
            if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) {
                this.onDeleted(context, new int[] { appWidgetId });
            }
        } else {

            Intent service = new Intent(context, weatherForecast.class);
               service.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
               context.startService(service);
        }



           super.onReceive(context, intent);
        }

    public void onDisabled(Context context) {
        context.stopService(new Intent(context,weatherForecast.class));
        super.onDisabled(context);
}

}   
</code></pre>
