android-remove the file named suffix under SDcard card

Source: Internet
Author: User

android--remove the file named suffix on the SDcard card

1.

Import java.io.file;import java.io.filenamefilter;/** * suffix name filter * @author ZLQ * */public class Filenameselector implements filenamefilter{string extension = "."; public filenameselector (String fileextensionnodot) {  extension + = Fileextensionnodot; Public  Boolean Accept (File dir, String name) {  return name.endswith (extension);}}


2.

public class Androidsdcardactivity extends activity {/** Called when the activity is first created. */@Override Public V OID onCreate (Bundle savedinstancestate) {  super.oncreate (savedinstancestate);  Setcontentview (r.layout.main);  GetName (); }  /**  * Gets the file ending with MP3 */public  void GetName () {file  file = Environment.getexternalstoragedirectory ();  if (file = null) {   file[] files = file.listfiles (New Filenameselector ("MP3"));   for (int i = 0; i < files.length; ++i) {    log.i ("System.out", Files[i].getname ());}}}  

android-remove the file named suffix under SDcard card

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.