tags:

views:

521

answers:

3

I am trying to follow an eclipse and android tutorial from ibm. The source code from the tutorial is giving me an error that says ContentURI cannot be resolved to a type..

here is the source code line...

ContentURI theContact = new ContentURI(android.provider.Contacts.ContactMethods.CONTENT_URI.toURI());

eclipse wanted me to fix it by either creating a class an interface or changing it to ContentUris

I tried the last one w/no luck so was looking for some advice.

A: 

The Contacts.ContactMethods class is deprecated. Have you tried ContactsContract?

Dinedal
I am trying this now...I found sample code on the android Developers Resources...but now it says ContactsContracts.Contacts cannot be resolvedEclipse wants me to either create a constant or a field called Contacts in ContactsContract, but neither of those things feels like the right thing to do...because that should already be in that public class right?Here is the exact line of code causing me grief:Uri uri = ContactsContract.Contacts.CONTENT_URI;
jkmcgee
OK, so changed project to updated version of android after finding some really informative "reflection" stuff. So no more errors...just warnings.
jkmcgee
+1  A: 

ContentURI was replaced back around Android 0.9, about 18 months ago. Check the age of your tutorial -- it is probably from the summer of 2008 and is now out of date.

CommonsWare
+1  A: 

The class ContentUri was replaced with the Uri class.

I would change that line to be:

Uri theContact = android.provider.Contacts.ContactMethods.CONTENT_URI;

Or find a more up-to-date tutorial, as the one you are looking at is probably going to have other out-of-date references.

mbaird
I would love a more up-to-date tutorial...any reccomendations? This one was not that easy to find, but what a great way to learn right? Debugging a tutorial. It is from ibm, www6.software.ibm.com under developerworks sowewhere.
jkmcgee
What was the tutorial on? You never provided a link to it. There are lots of tutorials out there, but what is the subject you are looking for?
mbaird
This particular tutorial is at http://www6.software.ibm.com/developerworks sorry, just the url and not a "link".They say the tutorial is supposed to get an address from a contact and then pass to google maps to get the location for a service worker to map out service calls.I've been trying to get ContactsContract class working by using some sample code from android developer resources...but that of course is causing other head aches.
jkmcgee