I\'m in my early days of learning Java but hopefully someone get explain what I\'m doing wrong here, numerous Google searches have left my head spinning.
I\'ve been
There's a bunch of stuff wrong here. First of all, Activity
classes, or in your case AppCompatActivity
classes are generally for presenting screens with UI, not performing discreet tasks. Your getSaved()
function should probably just reside in whichever Activity actually houses your UI.
Second, AppCompatActivity
classes can't perform context actions statically. In other words, your Activity needs to be instantiated before you can use its super class methods, in this case getFilesDir()
.
What that boils down to is that you need to initialize filename
in a lifecycle function, probably onCreate()