1

I've got an app that pulls XML from the Web, and caches it locally. As parsing XML is expensive compared to parsing Android binary XML, I'd like to store my local copy as Android binary XML. I haven't spotted an API for creating Android binary XML on the fly though, only the C/C++ code used by AAPT.

My motivation for taking this approach is that I don't currently use all the XML values/attributes, but may want to use more of them in a future version of my app, and don't want to download all the XML data again.

Can someone point me at the right bits of the API to create Android binary XML at run-time?

Many thanks,

Phil Lello

1 Answer 1

2

Android binary XML is faster because it is optimized by the compiler. In runtime, you can't create binary XML without having an implementation of the compiler to do it for you.

Sign up to request clarification or add additional context in comments.

3 Comments

I was afraid of that. I'll look into writing one then - probably move aapt code to a lib and wrap in JNI
I'm not sure it would even work in that case. In order for it to be optimized for your application, it would have to be a part of your bundle. This would be where the topic goes over my head, but I'm pretty sure the underlying OS won't let you write to the bundle.
I think it should work, but I'm by no means certain. I'm hopeful that XmlPullParser will be able to work with arbitrary binary XML files - the optimisation used in the binary XML comes from the string table and WBXML-esque tokenisation of structure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.