Reputation: 1092
I read the definition of the URI class here and here, but I'm still not sure how I would use an URI object in a android project since the second answer does not address URI in its specific use cases. Does anyone have a better insight on what an URI object can be used for? In what kinds of circumstances should I instantiate an URI object? When is an URI object useful and why should I create one? It would be helpful to have a concrete example. Below is an example I found by creating a blank dialog via Android Studio (factory method provided when one creates).
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
}
or
public interface OnFragmentInteractionListener {
void onFragmentInteraction(Uri uri);
}
If the examples above are not helpful you could use your own explanation as when a developer should consider creating an URI object. Thanks.
Upvotes: 0
Views: 1020
Reputation: 72
@CBA110 you can consider URI as a local address in your android system.Since i have used the Contacts URI i consider this way.Contacts URI is the contacts database and if you want to query any contact from this database you need to use this contacts URI which is serving as the local address with in your android phone/system and retrieves the contact you need.Please don't mine if you don't understand it.
Upvotes: 2