I want to load a keystore in my Android application. I have copied the key (truststore.bks) into the folder res/raw. The SDK from Android generate the R.java with a entry for trustsotre. In the App in try to use:
Resources.getSystem().openRawResource(R.raw.truststore);
But I get always a exception:
android.content.res.Resources$NotFoundException: Resource ID #0x7f040000
I look into the apk File und saw the truststore.bks file is in the folderres/raw/.
What is my misstake?
The problem is that you are using the system level resources with the call to Resources.getSystem. Specifically the documentation states that this does not provide access to application resources. You need to call getResources on a Context object in your application – all your activities are a Context object since they inherit from Context.