Книга: Beginning Android

getType()

getType()

The last method you need to implement is getType(). This takes a Uri and returns the MIME type associated with that Uri. The Uri could be a collection or an instance Uri; you need to determine which was provided and return the corresponding MIME type.

For example, here is getType() from Provider:

@Override
public String getType(Uri url) {
 if (isCollectionUri(url)) {
  return(getCollectionType());
 }
 return(getSingleType());
}

As you can see, most of the logic delegates to private getCollectionType() and getSingleType() methods:

private String getCollectionType() {
 return("vnd.android.cursor.dir/vnd.commonsware.constant");
}
private String getSingleType() {
 return("vnd.android.cursor.item/vnd.commonsware.constant");
}

Оглавление книги

Оглавление статьи/книги

Генерация: 0.040. Запросов К БД/Cache: 0 / 0
поделиться
Вверх Вниз