package com.example.admin.s20172285_0910_02;

import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import java.io.File;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button btn;
        final EditText edt;
        btn = (Button) findViewById(R.id.btn);
        edt = (EditText) findViewById(R.id.edt);

        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String sysDir = Environment.getRootDirectory()
                        .getAbsolutePath();
                File[] sysFiles = (new File(sysDir).listFiles());

                String strFname;
                for (int i =0 ; i<sysFiles.length; i++){
                    if (sysFiles[i].isDirectory() ==true)
                        strFname="<폴더>"+sysFiles[i].toString();
                    else
                        strFname="<파일>"+ sysFiles[i].toString();

                    edt.setText(edt.getText()+"\n"+strFname);
                }
            }
        });
    }
}
