Please tell me how to protect our resource in a apk package. With a simple rename-extract process, any one can copy and thief application drawable resource like images or soundFX files. My question is, is there any way to protect drawable resource in a Android application?
A drawable resource is a general concept for a graphic that can be drawn to the screen and which you can retrieve with APIs such as getDrawable(int) or apply to another XML resource with attributes such as android:drawable and android:icon . There are several different types of drawables: Bitmap File.
Accessing Resources When your Android application is compiled, a R class gets generated, which contains resource IDs for all the resources available in your res/ directory. You can use R class to access that resource using sub-directory and resource name or directly resource ID.
Resources are the additional files and static content that your code uses, such as bitmaps, layout definitions, user interface strings, animation instructions, and more. You should always externalize app resources such as images and strings from your code, so that you can maintain them independently.
The drawable needs to be accessible to the operating system, so it has to be readable.
If you really want to keep it secure, you could consider storing it encrypted as a raw asset, then load it, decrypt it into a ByteStream and pass it into the BitmapFactory. That, of course, has slight performance ramifications and will force you to hand-code a lot of stuff that you could have easily done in XML otherwise.
That all aside, there are many ways to steal data - if it's a drawable, people could just take a screenshot.
My question is, is there any way to protect drawable resource in a Android application?
No. Resources are world-readable by design. Even if you were to not package the "images or soundFX files" as resources but were to download them on first run, users with root access could still get to the files.
Since this is not significantly different than any other popular operating system humanity has developed, it is unclear why you think this is an Android problem. Sufficiently interested users can get at your "images or soundFX files" on iOS, Windows, OS X, Linux, and so on. Even Web apps are not immune.
I think it's possible to protect resources. In fact there's low-level class/routine to read resources: AssetManager
- ordinary Resources
class sits on top those AssetManager
. So to protect resource one can scramble resources and read/unscramble them using AssetManager low-level methods: look here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With