AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.aslam.contentproviderexample2" >
<uses-permission android:name="android.permission.READ_CONTACTS" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ListView
android:id="@+id/list_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</android.support.constraint.ConstraintLayout>
MainActivity.java
import android.Manifest;
import android.database.Cursor;
import android.provider.ContactsContract;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
ListView listView;
ArrayList al=new ArrayList();
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ActivityCompat.requestPermissions(MainActivity.this,new String[]{Manifest.permission.READ_CONTACTS},1);
listView=(ListView)findViewById(R.id.list_view);
Cursor cursor=getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,null,null,null,null);
while (cursor.moveToNext()){
String name= cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
al.add(name);
}
listView.setAdapter(new ArrayAdapter(MainActivity.this,android.R.layout.simple_list_item_1,al));
}
}
some errors are comming
ReplyDeleteThanks for sharing the useful blog about the Example Programs for Content Provider.
ReplyDeleteAndroid App development Company in Coimbatore
Hey Very Nice Blog!! Thanks For Sharing !!!
ReplyDeleteBest Website Developement Company in Lucknow
Top Digital Marketing Company in Lucknow
Digital Marketing in Lucknow
it really helpful for building a new app
ReplyDeleteAndroid App Development in chennai
Hey Nice Blog!!! Thank you for sharing information. Wonderful blog & good post.Its really helpful for me, waiting for a more new post. Keep Blogging!
ReplyDeleteAndroid Mobile App Developement Company
Graphic and Logo Designing Services
Best Web Hosting Provider Company in India
Thanks for your post. This is excellent information. It is amazing and wonderful to visit his site. digiorbite.com
ReplyDelete(Thanks for this blogspot)
ReplyDeleteHigh class infrastructure ensures that our Android developers have ample of scope to show their creativity and deliver highly effective Android apps that can win more business for your organization. Elsner is a Leading Android App Development Company in the USA.
Hey Very Nice Blog!! Thanks For Sharing !!!
ReplyDeleteBest SEO Company in Allahabad
Best Digital Marketing Agency in Allahabad
Seo Services in Allahabad
Hey Very Nice Blog!! Thanks For Sharing !!!
ReplyDeleteBest SEO Company in Allahabad
Best Digital Marketing Agency in Allahabad
Seo Services in Allahabad
We are Ahmedabad based website Development and website Design Company. As a leading website development company, we have extensive website design and website development skills blended with the quality spirit of expertise must have element to help you establish your Internet presence or take it to the next level.
ReplyDeleteAnd I appreciate your work, I'm a great blogger.
ReplyDeleteThis article bothered me a lot.
I will bookmark your site and continue searching for new information.
crystaldiskinfo crack
wysiwyg web builder crack
anytrans crack
poweriso crack
Your website has a great design. Colors and themes that pop!
ReplyDeleteIs this a work of your own? Please respond again since I want to construct one of my own.
and I'd want to know where you've came from on this site
The item's name is derived from this location.
Sincerely,
tweakbit fixmypc crack
sandboxie crack
advanced video compressor crack
norton security crack
Let me introduce myself. I suspect that your website is having issues with browser compatibility.
ReplyDeleteDisplays your site without any issues, however Internet Explorer has some overlapping issues.
As a matter of fact, I just wanted to let you know what was going on. However, except from that, this is an excellent blog!
minitab crack
coreldraw graphics suite 12 crack
minitab crack
Thanks for writing this excellent article for us.
ReplyDeleteI have gained good stuff from this website. I am looking forward to your next article.
Not only that, but I am happy to share this post with my friends. Keep it up.
teracopy pro crack
teracopy pro crack
teracopy pro crack
teracopy pro crack
teracopy pro crack
teracopy pro crack
teracopy pro crack
Great post I would like to thank you for the efforts you have made in writing this interesting and knowledgeable article.
ReplyDeletefuel crack
Red Dead Redemption 2 Crack
heavy rain crack
Far Cry 5 Crack
Oh my goodness! Impressive article dude! Thanks, However I am having troubles with your RSS. I don’t understand the reason why I am unable to join it. Is there anybody having the same RSS issues? Anyone that knows the answer will you kindly respond? Thanx!!
ReplyDeleteavast premier crack
last day on earth survival apk
idm build crack
keyshot pro crack
surviving mars green planet crack
ccleaner professional crack
euro truck driver apk cracked mod
I am very impressed with your post because this post is very beneficial for me and provide a new knowledge to me. this blog has detailed information, its much more to learn from your blog post.I would like to thank you for the effort you put into writing this page.
ReplyDeleteI also hope that you will be able to check the same high-quality content later.Good work with the hard work you have done I appreciate your work thanks for sharing it. It Is very Wounder Full Post.This article is very helpful, I wondered about this amazing article.. This is very informative.
“you are doing a great job, and give us up to dated information”.
1click dvd copy pro crack
magix sound forge pro suite crack
adobe media encoder crack
tenorshare 4ukey for android crack
ram saver professional crack
Hello, I Am Mari. Nice Content. Thanks for presenting this enlightening article!! I appreciate your hard work behind this great article. Realizzer 3D
ReplyDelete