I want to make a button to be able to display selected document names from the downloads folder that can be found in the "My Files" app in android, but i cant seem to find the right path to get to the documents. Anyone knows the path? I have tried ways like
Environment.getExternalStorageState()
but im not getting the downloads folder, instead it goes to google drive to select. this is how im using the uri.
else if (btnNo == 5 ) {
// File downloads = new File(String.valueOf(Environment.getExternalStorageState()));
//create new file directory object
//File downloads = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath());
Uri selectedImage = data.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(selectedImage,
filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
File f = new File(picturePath);
tvOther = (TextView) findViewById(R.id.textViewOtherImage);
tvOther2 = (TextView) findViewById(R.id.textViewOtherImage2);
tvOther3 = (TextView) findViewById(R.id.textViewOtherImage3);
tvOther4 = (TextView) findViewById(R.id.textViewOtherImage4);
tvOther5 = (TextView) findViewById(R.id.textViewOtherImage5);
tvOther6 = (TextView) findViewById(R.id.textViewOtherImage6);
tvOther7 = (TextView) findViewById(R.id.textViewOtherImage7);
tvOther8 = (TextView) findViewById(R.id.textViewOtherImage8);
tvOther9 = (TextView) findViewById(R.id.textViewOtherImage9);
tvOther10 = (TextView) findViewById(R.id.textViewOtherImage10);
if (tvOther.getText() == "") {
tvOther.setText(addClickablePart("[" + f.getName() + "]"), TextView.BufferType.EDITABLE);
iv_3 = BMP.getBytes(BitmapFactory.decodeFile(picturePath));
to_attach_img_name_3 = f.getName();
imgArr[2] = to_attach_img_name_3;
also a problem with editing the textviews im using, i cant seem to delete the text using the spannable class. any help with that will be good
my codes for the spannable class
private SpannableStringBuilder addClickablePart2(String str) {
SpannableStringBuilder ssb = new SpannableStringBuilder(str);
int idx1 = str.indexOf("[");
int idx2 = 0;
while (idx1 != -1) {
idx2 = str.indexOf("]", idx1) + 1;
final String clickString = str.substring(idx1, idx2);
ssb.setSpan(new ClickableSpan() {
@Override
public void onClick(View widget) {
tvOther2.setText("");
}
}, idx1, idx2, 0);
idx1 = str.indexOf("[", idx2);
}
return ssb;
}