0

I believe that every application can get access to its own files, for example - to classes.dex file. I wonder how the application get access to its files?

and another question, can I fake this access and get access to another application.?

Rishi Paul
  • 936
  • 2
  • 8
  • 25
jASON
  • 1
  • 1
  • 2
    you want access to my application? no, no way... i don't agree – pskink Jun 03 '15 at 08:15
  • Very funny... c(-: i wanted to create hash of any classes.dex on my device. – jASON Jun 03 '15 at 08:19
  • hash? what do you mean? – pskink Jun 03 '15 at 08:20
  • [This answer](http://stackoverflow.com/a/2508110/1841194) might help you out. After you've found an access to APKs, you need to extract them by a [zip library](http://stackoverflow.com/questions/9324933/what-is-a-good-java-library-to-zip-unzip-files) and then pick their `.dex` files – frogatto Jun 03 '15 at 08:34
  • I know how to work with Zipfiles and how to get the dex file, and generate an hash of his binary code - to create a digital signature of the file.. but how can I can the access to /data/app ? I dont want an application for rooted device only. – jASON Jun 03 '15 at 11:51

1 Answers1

2

you can point to the apk file of your application using ApplicationInfo.publicSourceDir

 File yourApk = new File(this.getApplicationInfo().publicSourceDir);
 //create the destination dir
 File tempDir = new File(getFilesDir(), "temp_dir");
 //and then unzip the apk to that dir
 unzip(yourApk , tempDir);
 //now the tempDir will contain all the resources including the dex file and its accessible

this file is a zip file you can decompress that file using this link

How to unzip files programmatically in Android?

so you will have the access to all resources plus the classes.dex

hope this will help

Community
  • 1
  • 1
M.Khouli
  • 3,992
  • 1
  • 23
  • 26
  • I know how to work with Zipfiles and how to get the dex file, and generate an hash of his binary code - to create a digital signature of the file.. but how can I can the access to /data/app ? I dont want an application for rooted device only. – jASON Jun 03 '15 at 11:53
  • you need to extract the apk(which is a zipped file) and store the content in a local directory so you can access the .dex file File yourApk = new File(this.getApplicationInfo().publicSourceDir); //now create the destination dir File tempDir = new File(getFilesDir(), "temp_dir"); //and then unzip the apk to that dir unzip(yourApk , tempDir); – M.Khouli Jun 03 '15 at 12:33