Saturday 15 September 2012

android - Trying to write and update contacts -


I am trying to write and then to update the contact using the URI content: //com.android Contacts / contacts and I'm getting a runtime error: URI 10101 is not allowed in Yuri content: //com.android.contacts/contacts I have declared permission in the manifest file

here is the code < / P>

  The public class increases the main activity activity (protected string [] names = {"Anda", "Candy", "Dandy"}; Tring [] numbers = { "12345678900", "14035567890", "12392344556"}; protect Int [] Aids = {1,2,3}; TextView txt; List View List Content value CV, Uri u, @ Override protected Create zero (bundle saved Instansstet) {Suprknkret (saved Instensstet); setContentView (R.layout.activity_main); Txt = (TextView) findViewById (R.id.txt); List = (ListView) findViewById (R .id.list); Uri Uri = The Thierry (); GraduationReference ("ContactContact.com.comDataDind.phone Contribution", Yuri, 2); Insert communication (name, number, id); ShowContacts (); UpdateContact (); ShowContacts (); } Public stable URI getTheUri () {// Return Uri.parse ("Content: //com.android.contacts/data/phones"); Return Uri. From ("Content: //com.android.contacts/contacts"); // return Uri.from ("content: // contact / people"); } Safe Dot Contact (String [] Name, String [] Number, Ent [] ID) {ContentValues ​​cv = new ContentValues ​​(); This.grantUri promotion ("com.example.contactsdemo", Uri.parse ("content: //com.android.contacts/contacts"), MODE_WORLD_WRITEABLE); For (int i = 0; i & lt; names.length; i ++) {cv.put (contactctact.com.modetind.phon.diIKI, name [ii]); Cv.put (ContactsContract.CommonDataKinds.Phone.NUMBER, number [i]); Cv.put (ContactsContract.CommonDataKinds.Phone._ID, ID [i]); U = getContentResolver (). Insert (ContactsContract.CommonDataKinds.Phone.CONTENT_URI, CV); }} Secure void updateContact () {// Update Phone Number getContentResolver () Update (U, CV, ContactContact.com.comDemandInphonesphone .DISPLAY_NAME + "= Anda", New String [] {"18585541315"}); } Protected void Shows Contact () {string [] projection = new String [] {ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER, ContactsContract.CommonDataKinds.Phone._ID}; Int for [] = new int [] {R.ID.txtName, R.id.txtNumber}; Txt.setText (ContactsContract.PhoneLookup.CONTENT_FILTER_URI.toString ()); Uri Contact = Contact Communication. CommonDayind phone. Cursor managed kaiser = managed (contact, projection, blank, empty, zero); // Cursor managed Kaiser = cr.query (contact, projection, blank, null, empty); ListAdapter sca = New SimpleCursorAdapter (this, R.layout.list_entry, Managed Quasars, Projection, To); List.setAdapter (SCA); }   

}

and here "manifests file:

   Android app: allowBackup = "true" android: icon = "@ drawable / Aisi_lancr" android: label = "@ string / app_name" Andr Ed: theme = "@ style / Aepthym" Android: debuggable = "true" & gt; & lt; activity android: name = "ComkexamplekcontactsdemokMainActivity" android: label = "@ string / app_name" & gt; & Gt; Intro-filter & gt; & lt; Android: Action Android: Name = "android.intent.action.MAIN" /> Category &roid: name = "android.intent.category.LAUNCHER" / & Gt; & Lt; / Intent-filter & gt; & Lt; / Activity & gt; & Lt; / Apps & gt; & Lt; / Reveal & gt;   

How can I get rid of runtime error? Any help would be greatly appreciated.

Trying to change permission in your manifest that you are using sperm?

  & lt; Usage-permission Android: name = "android.permission.READ_CONTACTS" & gt; & Lt; / Usage-permission & gt; & Lt; Usage-permission Android: name = "android.permission.WRITE_CONTACTS" & gt; & Lt; / Usage-permission & gt;   

The full set of permission flag can be found

No comments:

Post a Comment