Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to protect drawable resource in Android application

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?

like image 436
RubyDeveloper Avatar asked Feb 10 '11 01:02

RubyDeveloper


People also ask

What are drawable resources in Android?

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.

What is a resource how we access resources in Android?

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.

Why resources in Android should be externalised?

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.


3 Answers

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.

like image 165
EboMike Avatar answered Oct 05 '22 16:10

EboMike


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.

like image 43
CommonsWare Avatar answered Oct 05 '22 16:10

CommonsWare


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

like image 42
Barmaley Avatar answered Oct 05 '22 16:10

Barmaley