@peilicanhelican
Everything that needs to be imported is imported, frankly Android Studio is great like that and I have mastered the Alt+Enter when it comes to importing xDD
I don't know how to code the whole accessing the external storage's downloads folder so for now what the button does is taking you here: Imgur: The most awesome images on the Internet
which isn't what I want and I'm pretty sure except of this part of the code that does what is shown on the pic:
Code:
btn = (FloatingActionButton) findViewById(R.id.addButton); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath() + "/external_sd/Downloads/"); intent.setDataAndType(uri, "*/*"); startActivity(Intent.createChooser(intent, "Open folder"));
the rest of it doesn't work:
Code:
root = new File(Environment.getExternalStorageDirectory().getAbsolutePath()); //getfile(root); for (int i = 0; i < fileList.size(); i++) { TextView textView = new TextView(this); textView.setText(fileList.get(i).getName()); textView.setPadding(5, 5, 5, 5); System.out.println(fileList.get(i).getName()); if (fileList.get(i).isDirectory()) { textView.setTextColor(Color.parseColor("#FF0000")); } view.addView(textView); } btn = (FloatingActionButton) findViewById(R.id.addButton); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath() + "/external_sd/Downloads"); intent.setDataAndType(uri, "*/*"); startActivity(Intent.createChooser(intent, "Open folder")); //Intent intent = new Intent(Intent.ACTION_GET_CONTENT); //Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath() + "/external_sd/Downloads"); //intent.setDataAndType(uri, "*/*"); //startActivity(Intent.createChooser(intent, "Open folder")); } }); } public ArrayList<File> getfile(File dir) { File listFile[] = dir.listFiles(); if (listFile != null && listFile.length > 0) { for (int i = 0; i < listFile.length; i++) { if (listFile[i].isDirectory()) { fileList.add(listFile[i]); getfile(listFile[i]); } else { if (listFile[i].getName().endsWith(".mobi") || listFile[i].getName().endsWith(".epub")) { fileList.add(listFile[i]); } } } } return fileList; } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if(resultCode==PICKFILE_RESULT_CODE){ Log.d("TAG", "File Uri " +data.getData()); } }
This is only the part of the code that is relevant to what I want to do, but I'll post the whole MainActivity if that might help. Also actually I just realized that since mobi and epub aren't recognizable files to the emulator maybe I should change the filtering to pdfs or something