I am programming a notepad android app but I am having difficulties with my Open button. How do i implement it so that when I click on it, a dialog box comes up with the .txt files saved in the folder I created on the SD card? Also, how do i load the chosen file to my current activity?
Thank You
Try the Following,
File f = new File(Environment.getExternalStorageDirectory() +"/"+ dirname);
if(f.isDirectory())
{
ArrayList<String> files= new ArrayList<String>();
File file = new File(Environment.getExternalStorageDirectory() +"/"+ dirname+"/");
File fileList[] = file.listFiles();
for(int i=0;i<fileList.length;i++)
{
files.add(filelist[i].getAbsolutePath());
//here you can get all files.
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.