0
  1. I want to read myself apk file size in JNI of NDK,my C code is follow:
  2. if (bflag==0){
  3. FILE* fp;
  4. fp=fopen( "/data/app/ziwu.ziwu.ziwu.apk", "r");
  5. fseek(fp,0,SEEK_END );
  6. int size=ftell(fp);
  7. if (size>183650&&size<193750)
  8. {
  9. bflag=1;
  10. }else{
  11. return (*env)->NewStringUTF(env, www2);
  12. }
  13. }
  14. this code in emulator2.1 run OK,but in real phone run not OK.
  15. how to access /data/app/my.apk on Android for JNI of NDK of normal App?
  16. I am a chinese,my English is not very good.
  17. i get my apk file size in NDK,so nobody can decompiler my java code to change my
  18. apk file size.
  19. Does emulator always have root permission?Otherwise why different from emulator
  20. and real phone?
  • you can do this using java follow this http://stackoverflow.com/a/2605838/1075066 – Its not blank Feb 27 '12 at 03:34
  • I do not want to use java,I want to use C,use JNI,use NDK. – user1234613 Feb 27 '12 at 04:18
  • because i do not want anyone counter compile my java code,so i use ndk – user1234613 Feb 27 '12 at 04:26
  • counter compile mean decompiler?i am chinese,my english is not very good – user1234613 Feb 27 '12 at 04:29
  • i do not understand the sentence "Though I cannot access /data/app, but I can access /data/app/SoftKeyboard.apk" in http://stackoverflow.com/questions/5742513/how-to-access-data-app-proc-on-android-for-normal-app/9458939#9458939 – user1234613 Feb 27 '12 at 04:31
  • _i do not understand the sentence "Though I cannot access /data/app, but I can access /data/app/SoftKeyboard.apk"_. The underlying file system is as Linux. Your app _(or the transient user that runs your app, if you want to use strict terms)_ does not have read permissions for the `/data/app` directory, but the files in this directory can be read by anyone (as long as she knows the exact path). – Alex Cohn Feb 16 '14 at 13:16

1 Answers1

0

If your app package is ziwu.ziwu.ziwu, then the APK file will most likely be "/data/app/ziwu.ziwu.ziwu-1.apk" and any process on the device has read access to this file. Only the root and the owner of this file (user system) have write permissions.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307