I have a library that I use in my application. In my library, I need to get a resource ( a bks file). I don't have a main activity in my library. How do I get a resource without an activity. Here is the code I have.
public class PostRequest {
Context context;
MyApplication application;
public String post(){
KeyStore trustStore = KeyStore.getInstance("BKS");
InputStream trustStoreStream = application.getResources().openRawResource(R.raw.certificate);
}
}
I am getting the error, Attempt to invoke virtual method getResources() on a null object reference.
I created a variable Context context
to and used that context.getResources().openRawResource(R.raw.certificate);
but still with no success. This is a library so I don't have MainActivity or any activity classes.