1) Pass to Context constructor
public class Eph { private Context context; int x1,x2; public Eph(Context context) { this.context = context; } void cChart() { new CopyAssetfiles(".*\\.st1", getApplicationContext()).copy(); SwE sw = new SwE(context.getFilesDir() + File.separator + "/epit"); } }
2) Inherit from Application
public class MyApplication extends Application { private static Context context; public void onCreate() { super.onCreate(); MyApplication.context = getApplicationContext(); } public static Context getAppContext() { return MyApplication.context; } }
then add in the manifest to the <application>
android:name="your.package.MyApplication"