Android Photo Browser (one) to return all picture files

Source: Internet
Author: User

  1. Start writing Android's Photo browser today
  2. The first thing to solve is to get sdcard below all the files that are pictures of the directory
  3. So I wrote a generic Java class to get the suffix is. jpg,.bmp.png.jpeg file
  4. Package com.jiangqq.utlis;
  5. Import Java.io.File;
  6. Import java.util.ArrayList;
  7. Public class FileUtils
  8. {
  9. Private static ArrayList filelist = new ArrayList ();
  10. Public static void Main (string[] args) {
  11. FileList ("d:/");
  12. }
  13. Public static void FileList (String strpath) {
  14. File dir = new file (strpath);
  15. file[] files = dir.listfiles ();
  16. if (files = = null)
  17. Return
  18. for (int i = 0; i < files.length; i++) {
  19. if (Files[i].isdirectory ()) {
  20. FileList (Files[i].getabsolutepath ());
  21. } Else {
  22. String strFileName = Files[i].getabsolutepath (). toLowerCase ();
  23. if (Strfilename.endswith (". jpg") | | strfilename.endswith ("PNG")
  24. || Strfilename.endswith (". jpeg")
  25. || Strfilename.endswith (". BMG")) {
  26. System.out.println ("---" + strfilename);
  27. Filelist.add (Files[i].getabsolutepath ());
  28. }
  29. }
  30. }
  31. }
  32. }
  33. =============================

Android Photo Browser (one) to return all picture files

Related Article

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.