I am developing an app, and in this activity a button is pressed and any file can be selected to be uploaded. The file chooser loads correctly, but all of the images are unselectable (greyed out). I added the READ_EXTERNAL_STORAGE permission to the Manifest file, but I have no idea why it still won't let me choose a file. Here is the code I am using
private Button uploadButton;
private TextView uploadFile;
private static final int PICKFILE_RESULT_CODE = 1;
private String selectedImagePath;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
uploadButton = (Button)findViewById(R.id.upload_button);
uploadFile = (TextView)findViewById(R.id.uploadFile);
uploadButton.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v){
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
startActivityForResult(intent, PICKFILE_RESULT_CODE);
}});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch(requestCode){
case PICKFILE_RESULT_CODE:
if (resultCode==RESULT_OK){
String FilePath = data.getData().getPath();
uploadFile.setText(FilePath);
}
break;
}
}