Ho inserito un log in metodo getType() che non viene mai stampato. Sto usando il codice di esempio del blocco note. Si prega di spiegare la 1a riga del commento del documento Java. Restituire null da getType() funziona anche bene. Qual è lo scopo del metodo getType()?ContentProvider Android getType() ha chiamato quando e perché
/**
* This is called when a client calls {@link android.content.ContentResolver#getType(Uri)}.
* Returns the MIME data type of the URI given as a parameter.
*
* @param uri The URI whose MIME type is desired.
* @return The MIME type of the URI.
* @throws IllegalArgumentException if the incoming URI pattern is invalid.
*/
@Override
public String getType(Uri uri)
{
Log.d("Suparna", "******getType()");
/*switch(uriMatcher.match(uri))
{
// ---get all books---
case BOOK_DETAILS:
return Book.Book_Details.CONTENT_TYPE;
// ---get a particular book---
case BOOK_DETAILS_ID:
return Book.Book_Details.CONTENT_ITEM_TYPE;
default:
throw new IllegalArgumentException("Unsupported URI: " + uri);
}*/
return null;
}
Il motivo per cui questa domanda non ha attirato l'attenzione è perché hai dimenticato di taggarlo con "android". :) –
http://stackoverflow.com/questions/5351669/why-use-contentprovider-gettype-to-get-mime-type potrebbe esserti d'aiuto. – boiledwater