Reputation: 13
I want to read my own android application file from code. I mean to say suppose my filename is abc.apk which has got installed on the phone.Now through the same application (abc.apk) , I want to read abc.apk file byte by byte . Is it possible through code.
EDIT : I am editing the question for further usage. How can I get the current filename of my android application through native code.
Thanks , Chetan
Upvotes: 0
Views: 217
Reputation: 12917
It is possible. Here is example project that does it: http://dl.dropbox.com/u/1923577/android_native_read_apk.7z
It includes all the source code (java nad C++). If you install apk file from bin folder and run on device it will print out to android log "D/TEST (18107): First 4 bytes = 50 4b 03 04". And that is exactly first 4 bytes of apk file (check it with hexeditor). I am running this on non-rooted device.
Upvotes: 1
Reputation: 46856
I don't think this possible on a stock device. data/app/ directory cannot be accessed directly without root.
Upvotes: 0