public static Context mContext;
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_LEFT_ICON);
        setContentView(R.layout.main_adapter);
        getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,
                android.R.drawable.ic_dialog_alert);
         mContext=getApplicationContext();
i already tried getbasecontext() and the result were same
nullpointerexception
and the code i call is
    ContentResolver cr=mContext.getContentResolver();
         Log.i("phones",mContext.toString());
        Cursor phones =
cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null,null,null, null);
wish that is any help with this scenario thx in advance
On Mon, May 7, 2012 at 11:01 AM, Jason Teagle <[email protected]>wrote:

> i  have problem with application context
>> when i call ContentResolver cr=mContext.**getContentResolver(); its
>> return nullpointerexception and is coz of the appContext how i can
>> reslove that any help with that thx on advance
>>
>
> Where is 'mContext' set? If you could show us the lines of code where it
> is declared and later set, that would help.
>
> Since you are creating your own class here, you could pass the application
> context into this class' constructor for storage - but since you are
> [apparently] storing the context as a member variable, I would hope you are
> already doing something like that somewhere...
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to 
> android-developers@**googlegroups.com<[email protected]>
> To unsubscribe from this group, send email to
> android-developers+**[email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/**group/android-developers?hl=en<http://groups.google.com/group/android-developers?hl=en>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to