1

How to open and pick file by click load button? I want to show a sd card location when I click on load button and pick any file from there and display on main screen selected files.

Can anyone help me on how to show selected files from SD card display on screen?

Button loadButton = (Button) findViewById(R.id.loadButton);
loadButton.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {

    }
});
Michaël
  • 3,679
  • 7
  • 39
  • 64
Hayya Anam
  • 11
  • 4

1 Answers1

0

You need to start activity Add following code in Manifasto.xml file

<activity
            android:name=".fileDialog"
            android:configChanges="orientation"
            android:screenOrientation="reverseLandscape" />

in your java You need to add method

public void onButtonClick(View v) {
        pathSelect = "/sdcard/";
        Intent myIntent = new Intent(getBaseContext(),
                fileDialog.class);
        myIntent.putExtra(fileDialog.START_PATH,
                pathSelect);
    startActivityForResult(pathSelect, REQUEST_SAVE);       
    }

public synchronized void onActivityResult(final int requestCode,
            int resultCode, final Intent data) {
        String filename = "null";
        if (resultCode == Activity.RESULT_OK) {
            filename = data.getStringExtra(FileDialog.RESULT_PATH);         
        } else if (resultCode == Activity.RESULT_CANCELED) {
// do on cancle button click
                            }
}