The content below is from the Android developer site:
According to the phrase it is expecting the developer to store this info in his head. Shouldn’t this be simple if they kept only setDataAndType
and let user to set both, either or none, in which we don’t have to remember this caveat since it is taken care by design.
As the code is from Google, I would like to check with the community if there is any good reason for they doing this that I am missing to see?
Signatures:
setType(String)
setData(Uri)
setDataAndType(Uri, String)
1
From the fragment you show there is no good reason – if both URI type and MIME type can be present simultaneously, it seems strange to null either when setting the other. There might be hidden reasons, but I can’t think of any right now, therefore I’m leaning towards “This just isn’t a very good API”.
(Note also that the API talks about “type” and “data”, but the documentation talks about “URI” and “MIME type”. Such inconsistent language is another sign of an inexperienced API writer.)
0