-4

I have been attempting to declare an array but there is this NullPointer that comes up and prevents me from continuing. Also, I do not have access to LogCat because my Android Version now requires root for that. I am developing purely on a device with only AIDE.

I cannot implicitly paste code here because my device will not allow, so I have my codes put into PasteBin pages.

MainActivity.java It is at line 45 of the above paste that the NullPointer turns up on

AppFiles.java This is the File that is being referenced with the MainActivity class.

Blisskarthik
  • 1,250
  • 8
  • 20

2 Answers2

1

It seems you haven't initialized an Array object for itemStrings

replace your code public static String[] itemStrings; with this,

 public static String[] itemStrings = new String[Your_Array_Length]; 
user3717646
  • 436
  • 2
  • 10
0

I state the obvious: One of your file types is not there and you get the NPE for that.

The basic issue is that you return null in your return*() methods instead of an empty File[] array. So basically try that:

// just one of the methods picked as an example
public static File[] returnAssignments() {
    Assignments assignments = new Assignments();
    if (assignments.filePath.exists()) {
        return assignments.filePath.listFiles();
    }
    return new File[0];
}

That would prevent your AppFiles.getFileCount(type) to throw an NPE if no file for that type was found.

WarrenFaith
  • 56,949
  • 25
  • 133
  • 147