Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File dialog crashes with NullPointerException #2

Closed
GoogleCodeExporter opened this issue Mar 14, 2016 · 2 comments
Closed

File dialog crashes with NullPointerException #2

GoogleCodeExporter opened this issue Mar 14, 2016 · 2 comments

Comments

@GoogleCodeExporter
Copy link

File dialog crashes with NullPointerException if dirPath does not exists.

03-10 18:15:17.289: ERROR/AndroidRuntime(1438): Caused by: 
java.lang.NullPointerException
03-10 18:15:17.289: ERROR/AndroidRuntime(1438):     at 
com.loudsoft.loudbook.FileDialog.getDirImpl(FileDialog.java:177)
03-10 18:15:17.289: ERROR/AndroidRuntime(1438):     at 
com.loudsoft.loudbook.FileDialog.getDir(FileDialog.java:137)
03-10 18:15:17.289: ERROR/AndroidRuntime(1438):     at 
com.loudsoft.loudbook.FileDialog.onCreate(FileDialog.java:125)
03-10 18:15:17.289: ERROR/AndroidRuntime(1438):     at 
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-10 18:15:17.289: ERROR/AndroidRuntime(1438):     at 
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)

I offer this solution:

    private void getDirImpl(String dirPath) {

        File f = new File(dirPath);
                // Use root directory if dirPath does not exists
        if(!f.exists())
        {
            Toast.makeText(context, "There is no such directory " + dirPath, duration).show();
            dirPath = root;
            f = new File(root);
        }

        myPath.setText(getText(R.string.location) + ": " + dirPath);
        currentPath = dirPath;

        item = new ArrayList<String>();
        path = new ArrayList<String>();
        mList = new ArrayList<HashMap<String, Object>>();

        File[] files = f.listFiles();

Такие дела =)

Original issue reported on code.google.com by ppv....@gmail.com on 10 Mar 2011 at 3:31

@GoogleCodeExporter
Copy link
Author

Надо посмотреть :)

Original comment by alexande...@gmail.com on 24 Mar 2011 at 9:42

  • Added labels: Priority-High
  • Removed labels: Priority-Medium

@GoogleCodeExporter
Copy link
Author

ppv....@gmail.com, thanks a lot for your report, I've fixed the bug :)

Original comment by alexande...@gmail.com on 18 Aug 2011 at 7:44

  • Changed state: Fixed

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

No branches or pull requests

1 participant