Write/create file within Android Instrumentation context

I can’t recall when this was changed, but the current method to get a Context object during Instrumented testing is to import

import android.support.test.InstrumentationRegistry;

and call

InstrumentationRegistry.getContext();

Hope this helps!

Leave a Comment