How do I use the fileList()
method from the context class? What am I doing wrong here?
Context conData;
conData = new Context();
String[] instrumentFileList = new conData().fileList();
Any help is appreciated
How do I use the fileList()
method from the context class? What am I doing wrong here?
Context conData;
conData = new Context();
String[] instrumentFileList = new conData().fileList();
Any help is appreciated
As in Doc:
fileList() : Returns an array of strings naming the private files associated with this Context's application package.
means you should use Context associated with application to call fileList()
instead of by creating Context
class instance to get list of private files associated with application.
You can get list of files in Activity as:
String[] instrumentFileList = YourActivityName.this.fileList();
Simply change this from
to
You have already created instance by this
conData = new Context();
If
Context
is your non activity class then you can use above code. But you just want to useContext
of app then you can usegetApplicationContext();