title: Android: cannot resolve method createPackageContext() error
body: <p>I am new to Android. Using Android Studio, I am creating two Application applications where I need to send a shared preference value from one application to another application. I've tried the following code:</p>
  
  <p>APPLICATION-I
  Java File:</p>
  
  <pre><code> SharedPreferences sharedPreferences = getSharedPreferences("swlpref",Context.MODE_WORLD_READABLE);
      final String password = sharedPreferences.getString(PASSWD, "empty");
      final String rpassword = sharedPreferences.getString(RPASSWD, "empty");
  
              if (password.equals(rpassword)) {
                  TextView textViewPass = (TextView) findViewById(R.id.pass_pref_text);
                  textViewPass.setText(String.valueOf(password));
                  SharedPreferences.Editor editor = sharedPreferences.edit();
                  editor.putString("swlstring", password);
                  editor.commit();
              }
              else
              {
                  Toast.makeText(getBaseContext(), "Password does not match",   Toast.LENGTH_SHORT).show();
              }
  </code></pre>
  
  <p>APPLICATION-II Java File:</p>
  
  <pre><code>power.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              Context con;
              try {
                  con = createPackageContext("com.gokul.security", Context.CONTEXT_IGNORE_SECURITY);
                  SharedPreferences pref = con.getSharedPreferences(
                          "swlpref", Context.MODE_PRIVATE);
                  String data = pref.getString("swlstring", "No Value");
              }
  
              catch (PackageManager.NameNotFoundException e) {
                  Log.e("Not data shared", e.toString());
              }
      }
  });
  </code></pre>
  
  <p>APPLICATION-I has no errors.But the problem is in Application-II, where</p>
  
  <blockquote>
    <p>cannot resolve method createPackageContext() </p>
  </blockquote>
  
  <p>error is shown.</p>
  
  <p>I've also imported android.content.Context package.</p>
  
  <p>Still I could not solve this error. I've been trying for several hours but unhelpful.</p>
  
  <p>Help Please. Thanks in Advance. </p>