I have two activities: In the first activity I am passing the String "pathName" to a second activity. I am receiving the extra okay and I can create a File from this path name. The problem arises when I try to call .listFiles() from that file.
Code: First Activity
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
String pathToSend = albumDirectory+albumList.get(position);
Intent i = new Intent(getBaseContext(),GalleryImageSlider.class);
i.putExtra("pathName", pathToSend);
startActivity(i);
}
Second Activity:
List<File> imageList;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_capture_gallery);
Intent i = getIntent();
filePath = i.getExtras().getString("pathName");
albumFile = new File(filePath);
Log.d("Fragment","File Path: " + albumFile.getAbsolutePath());
//I can see this directory on my tablet, and I can see the files within. So the file
path is correct
try{
imageList = Arrays.asList(albumFile.listFiles());
}
catch(NullPointerException e){
Log.e("Error", "NPE: " + e);
}
I understand that .listFiles returns null if there are no files to be read. But there are files, and I can see them when I look in my tablets file manager.
Anyone see a way to resolve this? Thanks before hand.