쥔장에겐 완전 사랑하는 사람이 있어요 ^-^♡


package com.kei.fileexplorer;

import java.io.File;
import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.widget.TextView;
import android.widget.Toast;

public class FileExplorer extends Activity {
 
 String mSdPath ="";
 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        String result = new String("");     
        TextView tv = (TextView)findViewById(R.id.text1);
       
        String ext = Environment.getExternalStorageState();

        if(ext.equals(Environment.MEDIA_MOUNTED)) {
         mSdPath = Environment.getExternalStorageDirectory().getAbsolutePath();
        } else {
         mSdPath = Environment.MEDIA_UNMOUNTED;
        }
       
        try{    
           File f = new File(mSdPath);
          
           String[] filenames = f.list(null);
          
           for (int i = 0; i < filenames.length ; i++){
            String filename = filenames[i];
            if (filename.toLowerCase().endsWith("jpg")) {
             result = result + filename + "\n";
            }
           }  
           
           tv.setText(result);
           
           }catch(Exception e){  
            Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();  
           }
    }
   
}

저작자 표시 비영리 변경 금지
신고
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by Keizwer Keiz

댓글을 달아주세요:: 네티켓은 기본, 스팸은 사절


카테고리

:: Keiz Story :: (349)
TechNical (197)
Another (145)
ENG, JPN Lang. (7)

Statistics Graph
Total : 508,695
Today : 28 Yesterday : 51

달력

«   2017/08   »
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Google

글 보관함

0
hit counter