У меня есть класс, который расширяет встроенный класс диалога, и я хочу получить доступ к sharedprefence в нем, но в этом случае имеет исключение нулевого указателя.Исключительное исключение указателя в Контексте, используемом в диалоговом классе
Вот мой код
public class DialogCancelOrder extends Dialog {
Context context;
public DialogCancelOrder(Context a, String orderid) {
super(a);
this.orderid = orderid;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sp = context.getSharedPreferences("afewtaps", Context.MODE_PRIVATE);
face = Typeface.createFromAsset(context.getAssets(), "fonts/Nunito-Regular.ttf");
face1 = Typeface.createFromAsset(context.getAssets(), "fonts/Rupee_Foradian_2.ttf");
}
Put context = a; в конструкторе –