Imagine the following scenario: some xml file is downloaded from server and stored on device. Inside this file is the proper android resource xml markup, for example:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="string_array_name">
<item>text_string</item>
</string-array>
</resources>
I wonder is it possible to somehow create a custom Resources object and make it read this custom xml file – so I can just reuse existing resource xml parsing mechanism?
Or is this a no-go and I must use XmlPullParser in this case?
You can’t reuse resource parser because it parses binary xml files, not text xml files.
You probably could’ve converted your xml into Android binary format and then somehow trick resource parser (assuming this is possible). But converting text xml to binray xml on server-side is relatively harder task then just write your custom XML parser.
By the way, the
aapttool is responsible for text to binary xml conversion (as part of android build process).