Advertisement
anhit92

TESTTTTT

Dec 27th, 2014
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.43 KB | None | 0 0
  1. package com.example.anhphotostory.createslide;
  2.  
  3. import java.io.File;
  4. import java.util.ArrayList;
  5.  
  6. import android.annotation.SuppressLint;
  7. import android.app.Activity;
  8. import android.os.Bundle;
  9. import android.util.Log;
  10.  
  11. import com.example.anhphotostory.R;
  12.  
  13. @SuppressLint("SdCardPath")
  14. public class SelectClip extends Activity {
  15.     private static ArrayList<String> fileList = new ArrayList<String>();
  16.  
  17.     @Override
  18.     protected void onCreate(Bundle savedInstanceState) {
  19.         // TODO Auto-generated method stub
  20.         super.onCreate(savedInstanceState);
  21.         setContentView(R.layout.gridview_selectclip);
  22.  
  23.         // ///////////////////////
  24.         final File folder = new File("/sdcard");
  25.         getfile(folder);
  26.  
  27.     }
  28.  
  29.     public ArrayList<String> getfile(File dir) {
  30.         File listFile[] = dir.listFiles();
  31.         if (listFile != null && listFile.length > 0) {
  32.             for (int i = 0; i < listFile.length; i++) {
  33.  
  34.                 if (listFile[i].isDirectory()) {
  35.                     getfile(listFile[i]);
  36.  
  37.                 } else {
  38.                     if (listFile[i].getName().endsWith(".png")
  39.                             || listFile[i].getName().endsWith(".jpg")
  40.                             || listFile[i].getName().endsWith(".jpeg")
  41.                             || listFile[i].getName().endsWith(".gif"))
  42.                         Log.d("" + listFile[i].getName(), "HOANGANH" + listFile[i].getName());
  43.  
  44.  
  45.                     {
  46.                         fileList.add(listFile[i].getAbsolutePath());
  47.                         Log.d("" + listFile[i].getName(), "HOANGANH" + listFile[i].getName());
  48.  
  49.                     }
  50.                 }
  51.  
  52.             }
  53.         }
  54.         return fileList;
  55.  
  56.     }
  57.  
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement