title: cannot make static reference error in line 42
body: <p>The code is to get contacts list. But for one error. Pleas help me resolve. 
  The mContext on line 42 returns and error "cannot make a <strong>static reference to the non-static</strong> method <code>getapplicationcontext()</code> from the type contextwrapper".</p>
  
  <pre><code>package com.example.demo;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileOutputStream;
  
  import android.app.Activity;
  import android.content.Context;
  import android.content.Intent;
  import android.content.res.AssetFileDescriptor;
  import android.database.Cursor;
  import android.net.Uri;
  import android.os.Bundle;
  import android.os.Environment;
  import android.provider.ContactsContract;
  import android.widget.ImageButton;
  
  import android.util.Log;
  import android.view.View;
    import android.view.View.OnClickListener;
  
  public class MainActivity extends Activity {
  
  ImageButton imageButton;
  Context mContext =  getApplicationContext();
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      addListenerOnButton();
      data();
      getVcardString();
  }
  public static void getVcardString() {   
  
  
      String path = null;     
      String vfile = null;; 
       vfile = "Contacts.vcf"; 
  
      Cursor phones =              mContext.getContentResolver(). query(ContactsContract.     CommonDataKinds.Phone.CONTENT_URI, null,null, null, null);
  
      phones.moveToFirst();
      Log.i("Number of contacts", "cursorCount" +phones.getCount());  
      for(int i =0;i&lt;phones.getCount();i++)   {       
  
           String lookupKey = phones.getString(phones.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
           Log.i("lookupKey", " " +lookupKey);
           Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_VCARD_URI, lookupKey);
           AssetFileDescriptor fd;
  
           try  {
               fd = mContext.getContentResolver().openAssetFileDescriptor(uri, "r");
               FileInputStream fis = fd.createInputStream();
               byte[] buf = new byte[(int) fd.getDeclaredLength()];
               fis.read(buf);
               String VCard = new String(buf);          
  
               path = Environment.getExternalStorageDirectory().toString() +    File.separator + vfile;
               FileOutputStream mFileOutputStream = new FileOutputStream(path, true);
               mFileOutputStream.write(VCard.toString().getBytes());    
  
               phones.moveToNext();               
  
               File filevcf = new File(path);
               Log.i("file", "file" +filevcf);
  
           }catch(Exception e1) {
               e1.printStackTrace();  
           }
      }       
      Log.i("TAG", "No Contacts in Your Phone");          
  }
  
  protected void data() {             
      File filelocation = filevcf ;     
      Intent sharingIntent = new Intent(Intent.ACTION_SEND);
      sharingIntent.setType("vnd.android.cursor.dir/email");      
      sharingIntent.setType("application/x-vcard");       
      sharingIntent.putExtra(Intent.EXTRA_EMAIL, "mail@gmail.com" );       sharingIntent.putExtra(Intent.EXTRA_STREAM,Uri.parse("file://"+filelocation.getAbsolutePath()));
      startActivity(Intent.createChooser(sharingIntent, "Send email"));            
   }  
  
  public void addListenerOnButton() {
      final Context context =   getApplicationContext();
  
  
      imageButton = (ImageButton) findViewById(R.id.imageButton1);
  
      imageButton.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View arg0) {
  
  
              Intent intent1 = new Intent(context, secondjav.class);
                          startActivity(intent1);   
  
  
          }
  
      });
  
    }
  
  }
  </code></pre>