I have a MainMenu activity that gets data from file and displays it. I want the data to be deleted at the start of each espresso test and to not persist between tests.
I have tried the following:
Context mContext;
@Before
public void setUp() {
mContext = InstrumentationRegistry.getInstrumentation().getContext();
File[] files = mContext.getFilesDir().listFiles();
if(files != null){
for(File file : files) {
file.delete();
}
}
}
However, it is not deleting the files. I believe the context might not be correct. Is there a way to clear internal storage at the start of an espresso test?
The files are '.ser' files.
In kotlin..