How to protect drawable resource in Android application

ぐ巨炮叔叔 提交于 2019-12-04 06:25:51

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!