Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

NullPointerException on back item #36

Closed
dacasals opened this issue Feb 19, 2017 · 3 comments
Closed

NullPointerException on back item #36

dacasals opened this issue Feb 19, 2017 · 3 comments

Comments

@dacasals
Copy link

Hello, when the first listview is loaded with directories and files of the specified path, and you press the first element to return (...), the application ends with errors. An uncontrolled nullPointerException is thrown.

@npes87184
Copy link
Contributor

You should indicate the correct root directory. For example: "/".

@themysteq
Copy link

themysteq commented Feb 19, 2017

@dacasals as docs said you should set your root property as the most parent - where the user can't go higher. It's boundary directory. The offset property is the directory which you want to show to user when dialog.show() is called. offset must be sub-directory of root or you will get NullPointerException.

In my example the most parent directory is Environment.getExternalStorageDirectory() so :

properties.root = Environment.getExternalStorageDirectory(); 
// in my device it's "/storage/emulated/0"

properties.offset = Environment.getExternalStorageDirectory()+ "/subfolder";
 // will be "/storage/emulated/0/subfolder"

@singhangadin
Copy link
Owner

Hi @dacasals ,
Just a few days after releasing library I received an email and an issue with a similar concern.
Here I will explain what was the issue with the library:
By default, library sets offset and root to sdcard location, You can see here.
While initializing the list, dialog checks whether an offset has been set or not. If set and location are valid, offset directory's files are shown in the dialog. This condition also adds the parent directory in the same listview. Now since you are presently in the root directory (as root and offset are same), parent directory shouldn't have been shown in the first place, next you cannot go before sdcard directory (You can't access any directory before sdcard as app don't have permission for that). Hence clicking the ... gave a NullpointerException. It was added in the root listview and wasn't supposed to be there. So in v1.0.9, I added extra checks to validate offset (That I should have added before!). You can see them here. This won't set an offset if offset equals root directory path or isn't a subdirectory of the root (Which covers the case @themysteq has mentioned). Hopefully, this was the case! If not, I would like to know what are the values you have set in root and offset properties. It is possible that os doesn't provide permission to access the directory which is the parent of offset.

P.S.: Lines tagged in links are marked with yellow color.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants