And*_*per 23 java android android-contentprovider
我在getType()方法中放入了一个永远不会被打印的日志.我正在使用记事本示例代码.请解释Java doc评论的第1行.从getType()返回null也正常工作.getType()方法的目的是什么?
/**
* 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;
}
Run Code Online (Sandbox Code Playgroud)
Ale*_*ood 35
getType(Uri uri)
通常只会在打电话后调用ContentResolver#getType(Uri uri)
.应用程序(其他第三方应用程序,如果ContentProvider
已导出或您自己的应用程序)使用它来检索给定内容URL的MIME类型.如果您的应用程序不关心数据的MIME类型,那么简单地使用该方法就完全没问题了return null
.
归档时间: |
|
查看次数: |
9398 次 |
最近记录: |