title: Sharedpreferences does not work with appWidgetProvider (getApplicationContext is undefined)
body: <p>I am creating a widget that will show some datas for the user from a database. One of the datas depends on a parameter that can be set in my settings activity. I save this parameter with sharedpreferences so I can use it anywhere in my code. 
  In an activity I could use getApplicationContext, but here where I tell the widget what to do, it doesnt work. What should I use instead of getApplicationContext?</p>
  
  <p><em><strong>UPDATED</em></strong></p>
  
  <pre><code>public class plWidget extends AppWidgetProvider{
  
      SharedPreferences sharedPreferences;
       String loadedWeightType;
  
      @Override
      public void onDeleted(Context context, int[] appWidgetIds) {
          // TODO Auto-generated method stub
          super.onDeleted(context, appWidgetIds);
          Toast.makeText(context, "deleted", 2500).show();
      }
  
      @Override
      public void onUpdate(Context context, AppWidgetManager appWidgetManager,
              int[] appWidgetIds) {
          // TODO Auto-generated method stub
          super.onUpdate(context, appWidgetManager, appWidgetIds);
  
           String Wcal="0",Wfat="0",Wprot="0",Wcarb="0",Wsport="0";
  
           final int N = appWidgetIds.length;
  
           for (int i = 0;i&lt;N;i++)
          {
              int awID = appWidgetIds[i];
              updateAppWidget(context, appWidgetManager, appWidgetIds[i]);
  
              GlobalVars.setSulyType(loadedWeightType);           
          Log.i("SULYYYY", GlobalVars.getSulyType());
  
          long now = System.currentTimeMillis();
          SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
          Date resultdate = new Date(now);
          Log.i("ASAS", sdf.format(resultdate));
  
  
          hornot database = new hornot(context);
          database.open();
  
  
  
           int ccc = database.checkDataExists(sdf.format(resultdate), sdf.format(resultdate));
          if (ccc==0){
              Log.i("nulla", "0");
              Log.i("nulla", GlobalVars.getSulyType());
  
              Wcal="0";
              Wfat="0";
              Wprot="0";
              Wcarb="0";
          }
  
          else{
  
          database.getDateFromAndToFromDatePicker(sdf.format(resultdate), sdf.format(resultdate));
           Wcal = GlobalVars.getSums();
  
          database.FATgetDateFromAndToFromDatePicker(sdf.format(resultdate), sdf.format(resultdate));
           Wfat = GlobalVars.getSums();
  
          database.PROTEINgetDateFromAndToFromDatePicker(sdf.format(resultdate), sdf.format(resultdate));
           Wprot = GlobalVars.getSums();
  
          database.CARBSgetDateFromAndToFromDatePicker(sdf.format(resultdate), sdf.format(resultdate));
           Wcarb = GlobalVars.getSums();
  
                  }
  
          int ddd = database.checkDataExistsSports(sdf.format(resultdate), sdf.format(resultdate));
          if (ddd==0){
              Wsport="0";
  
          }
          else{
  
              if (loadedWeightType.equals("kilogramm"))
                      {
              database.SportgetDateFromAndToFromDatePicker(sdf.format(resultdate), sdf.format(resultdate));
              // Wsport = GlobalVars.getSums();
               Wsport= "kilogramm";
  
  
                      }
              else if (loadedWeightType.equals("pound"))
                      {
              database.SportgetDateFromAndToFromDatePicker(sdf.format(resultdate), sdf.format(resultdate));
              Wsport="pound";
                      }
  
          }
  
          RemoteViews v = new RemoteViews(context.getPackageName(), R.layout.widget);
          v.setTextViewText(R.id.tvwidgetUpdate, Wcal+Wfat+Wprot+Wcarb+Wsport);
          appWidgetManager.updateAppWidget(awID, v);
          database.close();
  
  
  
          }
  
  
      }
  
      public void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) { 
          SharedPreferences prefs = context.getSharedPreferences(plWidget.class + Integer.toString(appWidgetId),
                  Context.MODE_WORLD_READABLE);
           loadedWeightType= prefs.getString("weighttype", "kilogramm");
      }
  
  }
  </code></pre>
  
  <p>Thanks in advance!</p>
  
  <p><em><strong>UPDATE</em></strong></p>
  
  <p>As usual I do the load funciton:</p>
  
  <pre><code> public void LoadWeightType(){
          sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
          loadedWeightType= sharedPreferences.getString("weighttype", "kilogramm");
        }
  </code></pre>
  
  <p>With this in a normal activity, I can load the weighttype. I guess that updateAppWidget function should somehow substitue this function.</p>