title: Probleme of Preferences in class extends Fragment
body: <pre><code>SharedPreferences prefs1 = getSharedPreferences("monfichierdeprefs",MODE_PRIVATE);
  </code></pre>
  
  <p>the same syntax works on a class extend activity but not in extends Fragment So I added context syntax error has disappeared but  when I press the button "demande" the application stops the error come from preferance I am sure I may not find the solution
  could you help me Please!!!!!</p>
  
  <pre><code>public class PageGaucheFragment extends Fragment {
  
   private static String KEY_SUCCESS = "success";
   private static String KEY_ERROR = "error";
   final String PARA_NOM = "parametre2";
   final String PARA_NOM1 = "parametre3";
   Context context;
   public String fname,lname,ftype;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
      View view = inflater.inflate(R.layout.page_gauche, container, false);
  
   /**
   * Action sur bouton demande 
  * **/       
  
  Button button = (Button) view.findViewById(R.id.button1);
      button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
          SharedPreferences  prefs1 = context.getSharedPreferences("monfichierdeprefs",Context.MODE_PRIVATE);
          fname = prefs1.getString(PARA_NOM, "");
               lname = prefs1.getString(PARA_NOM1, "");
              ftype="salut"; 
            //apelle de la fonction NetAsync qui verifie la connextion et envoie de demande 
            NetAsync(v);            
        }
      });
  
      return view;
  }
  </code></pre>