Moved file extension code out to its own method so that it can be used in MediaGridAdapter easily.