Everyone has been giving you the preferred solution and I don't disagree with the advice they are giving you.
You can access the res content directly, but it's a bit tricky. First of all, you need to understand that the res file is stored in your applications base.apk file. That file is a jar file, so you will need to process it using some jar api. The absolute path to this jar file can be obtained from ApplicationInfo. The value of ApplicationInfo.sourceDir is the path to the base.apk file. And by the way, sourceDir is read only. Here's some Java code for getting ApplicationInfo:
private ApplicationInfo getAppInfo() {
ApplicationInfo appInfo = null;
try {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) {
appInfo = getApplication().getPackageManager().getApplicationInfo(getApplication().getPackageName(), PackageManager.ApplicationInfoFlags.of(0));
} else {
appInfo = getApplication().getPackageManager().getApplicationInfo(getApplication().getPackageName(), PackageManager.GET_META_DATA);
}
} catch (PackageManager.NameNotFoundException e) {
if (appInfo == null) Log.e(TAG, "Package name not found: " + e.getMessage());
}
return appInfo;
}
Here's some code that I wrote the I use to copy the content in directory named webContent which was put in as as a directory in a resources file. (IOUtility is my own written code, but it nothing that special)
ApplicationInfo appInfo = getAppInfo();
String apkPath = appInfo.sourceDir;
JarFile apkJar = new JarFile(apkPath);
IOUtility.copyResourceDirectory(apkJar, "webContent", webContentDir);
apkJar.close();
I've looked at a base.apk file and saw res is available for you to access just like an other jar content. I'll give you a bit of warning, Android compiles some XML content as binary XML. So, XML content might not look like you expect it to look like. You can also access the Android assets directly using this approach. My advice is to use the Android facilities that are designed for accessing this kind of content unless you have some real need to bypass them.