David Welton: Bypassing Android's "Resources"
Android relies heavily on something called "resources" to access portions of the system that aren't directly in the Java code. For instance, if you had an ogg file that you wanted to use to play a sound with, you would add it as
res/raw/foo.ogg. Then, during compilation, the aapt tool transforms all your resources into a Java file called R.java, which is basically a series of integers that can be used to reference the actual resources. For instance, to set up our hypothetical ogg file, we would do:
MediaPlayer mp = MediaPlayer.create(context, R.raw.foo);
That's all well and good as far as it goes, and if you don't have any reason not to use it, you should.
However, with Hecl, one of my goals is to make it very easy to create applications. This means:
- No complex directory layout structure.
- No big long build files that require tools like ant.
- No complex compilation steps.
.apk file that actually gets installed on the phone. Since it's just a zip file, that's pretty easy:
zip -r Hecl.apk res/raw/foo.ogg
However, without a resource, there is no way to access that file, so the question is: how can we get ahold of it somehow?
The first piece of the puzzle is Java's ZipFile class, which lets us open up a zip compressed file, such as the .apk file that contains the ogg file we're interested in in this case.
The critical passage is getting ahold of the actual filename on the Android filesystem of the code that's currently running. It turns out to not be too difficult, if a bit obscure:
String filename = this.getPackageManager().getApplicationInfo(packagename, 0).sourceDir;
With that information in hand, we can feed it to ZipFile, and then access the contents at run time.
It's not a perfect nor complete solution, yet. So many of the Android API's require a resource ID, so it takes some extra coding to do things from the InputStream that we can get out of the zip file, but there may be ways to make this easier. For instance, we could simply dump the contents of raw/ into an application specific data directory the first time an application runs, in order to at least be able to access the files as files, rather than InputStreams connected to ZipEntries. In any case, at least it's possible to access files added to the .apk without requiring the compilation step.
I'm not sure how many other use cases there might be for direct access to the .apk file, but if other people need to do this, hopefully this information will be helpful.


Do you know the situation where you just aren’t sure whether you are spelling a word the right way? If you know how to type the word pretty well, then a dictionary might work just fine. If you aren’t sure at all you might consider using Google’s ‘Did you mean’-feature. Check out a simple demonstration for the word
This week I finally realized where problem with random crashes in Wammu
and python-gammu lies - python-gammu was using two version of C library
- mscvrt.dll and mscvr71.dll. First one came from Gammu and second one
from Python. Starting with 1.19.0, Gammu is built with mscvr71.dll and
random crashes are gone. Any tester did not report problems with Windows
binary, so I decided to make it finally an official release.
So after year or more Windows users can finally use up to date Wammu
version! Fortunately I can produce this version without even touching
Windows. Thanks to tools such as MinGW and Wine, everything from
compiling to generating installer can be scripted and done automatically
on Linux!
So Windows users can now also download current version from


I’ve released dsyslog 0.2 tonight with support for BSD syslog facility and severity decoding, as well as some other nice features. You can download the source
Oh, please, I don t think I ever had a favourite film:
I cannot remember what I wrote here when I signed up more than two years ago.
And, of course, there s something good about this form, and something (else) bad about it:
The bad: this is displayed just after it has verified my email address.
The good: at least it s not asking for my mother s maiden name.
In the Latvian l10n community we often deal with the problem of mistranslation of common words such as “file”, “preferences” and “advanced”. There are several words that fit each of those and over the years preferences in the community have shifted back and forth.
I just came up with an idea of making a script that would download all the translations, search for these common words in the source strings and see if any of the common translations and mistranslations are in the translation for that string. Then it could form up a web page with statistics of the mistranslations and possibly even links to specific instances to allow for corrections. It would also find new mistranslations
I’ve been provided the latest Verizon and Sprint EVDO cards to evaluate in the field for the past month. I now have to decide which to keep. It’s a close call (no pun intended).
I’ve tested them both over various areas in Greater Boston and Washington DC. Key observations:
(1) Speed: The Verizon card is usually faster. I’ve clocked up to 2.5 Mbps using the 
Often if you see a block diagram like this, what comes to mind is a
compatability layer in between a program and several operating systems.
Generally something that's general-purpose like java, or a web browser, or
a widget toolkit.
Or, as it's said,
Continuing from where we