티스토리 뷰

프로그래밍/Android

[Android] sdcard

DEV LION 2014. 1. 3. 09:05
package kr.priv.android_sdcard; 
  
import java.io.File; 
import java.util.ArrayList; 
import java.util.List; 
  
import android.app.Activity; 
import android.os.Bundle; 
import android.os.Environment; 
import android.util.Log; 
import android.view.Menu; 
import android.widget.ArrayAdapter; 
import android.widget.ListView; 
  
public class AT_main extends Activity { 
  
    List mFileNames = new ArrayList(); 
  
    @Override
    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
          
        ListView listview = new ListView(this); 
  
        setContentView(listview); 
        String root = Environment.getExternalStorageDirectory().getAbsolutePath(); 
// + File.separator + "sbin" + File.separator; 
        File f = new File(root); 
  
          
        for (File file : f.listFiles()) { 
            mFileNames.add(file.getName()); 
        } 
  
        ArrayAdapter adapter = new ArrayAdapter(this, 
                android.R.layout.simple_list_item_1, mFileNames); 
        listview.setAdapter(adapter); 
    } 
  
    @Override
    public boolean onCreateOptionsMenu(Menu menu) { 
        getMenuInflater().inflate(R.menu.main, menu); 
        return true; 
    } 
  
}
 
  
     
          
     
  

 
 

반응형
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/12   »
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
글 보관함