1

I have an app that use .jpg files in drawable folder to show in viewPager. I want to prevent simply steal my apk drawable files. so before loading them in drawable folder, I changed a unique word in .jpg file content name it Original

ےطےل Original  II*            ےى Ducky

to Fake.

ےطےل Fake  II*            ےى Ducky

this cause .Jpg file unreadable.then I load unreadable files to drawable folder.

I need a method that replace Fake to Original then send it to mResources. I have no idea how to do that please explain it step by step!!

class CustomPagerAdapter extends PagerAdapter {

int[] mResources = {
    R.drawable.first,
    R.drawable.second,
    R.drawable.third,
    R.drawable.fourth,
    R.drawable.fifth,
    R.drawable.sixth
};

Context mContext;
LayoutInflater mLayoutInflater;

public CustomPagerAdapter(Context context) {
    mContext = context;
    mLayoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

@Override
public int getCount() {
    return mResources.length;
}

@Override
public boolean isViewFromObject(View view, Object object) {
    return view == ((LinearLayout) object);
}

@Override
public Object instantiateItem(ViewGroup container, int position) {
    View itemView = mLayoutInflater.inflate(R.layout.pager_item, container, false);

    ImageView imageView = (ImageView) itemView.findViewById(R.id.imageView);
    imageView.setImageResource(mResources[position]);

    container.addView(itemView);

    return itemView;
}

@Override
public void destroyItem(ViewGroup container, int position, Object object) {
    container.removeView((LinearLayout) object);
}

}

Pingman98
  • 91
  • 1
  • 1
  • 7
  • You are not limited to read images as resource: http://stackoverflow.com/questions/4181774/show-image-view-from-file-path-in-android . Anyway, you say `I want to prevent simply steal my apk drawable files.`, that protection is not easy to do. – PeterMmm Sep 28 '15 at 17:52
  • yes but as I mentioned, my images are unreadable. I think you didn't read the question carefully – Pingman98 Sep 28 '15 at 17:56
  • They are not unreadable, they are unlocatable as you change the name. Probably I don't get you... – PeterMmm Sep 29 '15 at 18:10

1 Answers1

0

It's not the answer you want to hear, but...

I wouldn't spend much time trying to make your files unreadable. Even if you get it to work, you'll likely really slow down your app and/or make it less robust. And without a lot of extra hassle, you'll probably break all the automatic resource selection (for orientation, screen-density, etc.) that the OS does on you behalf.

Your altered drawables would probably still be readable by the more permissible graphics programs. And they will always be vulnerable to screen-grabs.

IMO, it would be better to spend the time making your app as good as you can and let your competitors try to play catch-up. Developing non-trivial Android apps can be challenging enough without attempting to override built-in behaviors.

scottt
  • 8,301
  • 1
  • 31
  • 41
  • ok you're right! but I have a book for sell that has 140 pages . i want to prevent at least ordinary users to simply grab whole pages from apk. i can't use web services, I tried use sqlite but failed... do you have any suggestion to solve my problem based the situation that i mentioned. any clue can be a big help! THANKS – Pingman98 Sep 29 '15 at 10:34