I ask an example of passing the context to the class through the constructor
class FirstClass{ // CΡΡΠ»ΠΊΠ° Π½Π° ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡ private Context context; //ΠΏΡΠΈΠ½ΠΈΠΌΠ°Π΅Ρ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡ Π² ΠΊΠΎΠ½ΡΡΡΡΠΊΡΡΠ΅ public YourTwoClass(Context context){ this.context=context; }
}
Or one more example with it you can get the context "everywhere"
public class MyApplication extends Application { static Context context; @Override public onCreate() { super.onCreate(); this.context = getApplicationContext() } public static Context getApplicationContext() { return this.context; } }
Do not forget to add to manifest and then throw an error
<application android:name=".MyApplication" </application>
and here is our hero
MyApplication.getContext(); // ΠΏΠΎΠ»ΡΡΠ°ΠΉ Π»ΡΠ±ΠΈΠΌΡΠΉ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡ)))