getContentResolver()怎么用?

Cursor c = getContentResolver().query(Phones.CONTENT_URI, null, null, null, null);我看解释是getContentResolver()方法的到应用的ContentResolver,刚接触Android,对里面的很多的方法都弄不清,而且我还没找到getContentResolver()方法是出自哪个类,好纠结啊!这Android啥时候才能学的精啊!!!!

用ContentProvider时会用,比如访问系统内置的一些数据库,或者自己建一个库,提供他其他应用程序调用时会用到。Cursor c = getContentResolver().query(Phones.CONTENT_URI, null, null, null, null);其实应该是Cursor c =context.getContentResolver().query(Phones.CONTENT_URI, null, null, null, null);在Activity里用当然没问题,要是在自己定义的一个公用的类里用,就需要传Context对象了。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-07-14
用ContentProvider的时候才会用到的,通过ContentProvider提供的URI接口来获取里面封装的数据
相似回答