Android: display the SD card file list

Source: Internet
Author: User

Read the SD card file information and add it to the listview to display it:

 

Listview obtains the information of the SD FileCode:

List <Map <string, Object> List = new arraylist <Map <string, Object> (); <br/> string sdstatestring = environment. getexternalstoragestate (); <br/> If (sdstatestring. equals (environment. media_mounted) {<br/> try {<br/> file sdfile = environment. getexternalstoragedirectory (); <br/> file sdpath = new file (sdfile. getabsolutepath (); <br/> If (sdpath. listfiles (). length> 0) {<br/> for (File file: sdpath. listfiles () {<br/> Map <string, Object> map = new hashmap <string, Object> (); <br/> map. put ("text_content", file. getname (); // get filename <br/> list. add (MAP); <br/>}< br/>} catch (exception E) {<br/> // <br/>}< br/> return list; 

Draw different images based on filetype:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.