1

Moving to SD Card actually copies the apk in /data/app folder to SD card. I wanted to do the same from my code.

I tried this but it failed as canWrite(), setWriteable(true) and delete() returns false

File apkFile = new File(info.activityInfo.applicationInfo.sourceDir);
apkfile.delete();

Is it at all possible to delete/move the apk to sd Card (and not copy it)?

FYI: installLocation would not help me. So, I had to take the above approach.

thepace
  • 2,221
  • 1
  • 13
  • 21

1 Answers1

1

You can not move /delete installed apk file without ROOT privileges .

If you want to move/delete installed apk than you need a ROOTED android device. becase installed apk is inside system/ directory and it is mounted as read-only. I had to remount it with this

mount -o remount,rw /system

Read more about how to write files to system/ ?

Community
  • 1
  • 1
prakash ubhadiya
  • 1,242
  • 1
  • 12
  • 24
  • Does this apply for the same apk i.e if sample.apk was installed and the code inside sample.apk wants to remove the sample apk after installation, isn't that possible? – thepace Nov 08 '16 at 12:26