Skip to content

Bug: To fix a NullPointerException in ShareDataActivity #650

@radcolor

Description

@radcolor
  • Description
    In ShareDataActivity we checking if appDir.listFiles() != null to continue our work. Though in L68 we trying to get the length of our File array fileList = new String[files.length] without even checking if our array is null or not and that can lead to Crash and Runtime exception if array found null, and can lead to poor user experience

  • Expected Behavior
    If the our CSV dir doesn't exist then no need to call ShareDataActivity, either we can check for the csv file list before calling it in NeuroLab.java on method onNavigationItemSelected() or either to get array length of file after confirming that our array is not null and if found null then show a message to user that our file doesn't exist/no data to share!

  • Steps to reproduce it
    If our CSV dir is empty or file are null, then ShareDataActivity will crash because of null array

  • System Information

DeviceXiaomi Redmi Note 5 Pro/AI (whyred)
Android version/OSAndroid Q (API 29)

I'll provide a runtime crash screenshot below! I can have a PR over here to fix this!

Screenshot from 2020-07-21 01-53-06

Metadata

Metadata

Assignees

No one assigned

    Labels

    hacktoberfestIssue eligible for hacktoberfest

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions