Skip to content Skip to sidebar Skip to footer

Why In A Test Class That Extends Androidtestcase, Does Getcontext() Return Null?

I have my own SQLiteOpenHelper as follow : public class MyOpenHelper extends SQLiteOpenHelper { public static final int DB_VERSION = 1; public static final String DB_NAME = '

Solution 1:

For accessing a context you can:

  1. Extend from InstrumentationTestCase and then call getInstrumentation().getContext()
  2. Use reflection to access a private member

You can see code samples at this answer

Post a Comment for "Why In A Test Class That Extends Androidtestcase, Does Getcontext() Return Null?"