Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

I would like to take an installed app, including its data, from a rooted Android device and produce from it an APK suitable for installing on a non-rooted Android device.

Is this possible?

Edit: Existing answers/comments seem to reinforce the idea that existing apps do not support embedding an app's data within an APK. Perhaps the more fundamental question is,can an APK embed files destined for /data/data/[appname], or are they restricted to being self-contained when installed?

Notes:

  • I assumed that, if it were possible, this functionality would be built into an app such as Titanium Backup. Titanium Backup can back up app+data to a single file, but that file is not an APK and can only be restored by Titanium Backup itself - which is no help for me as the destination device is not rooted and so cannot run TB.
  • Solutions that require use of the terminal on the phone or ADB are fine.

Thanks.

share|improve this question
    
If you look into TB's backup folder you will note it stores the .apk plain (so at least you can take that). I need to look into the data files; AFAIR this were simply stored properties, but I cannot remember the format used. However, restoring data on a non-rooted device is probably very hard to achieve for the same reason as backup is: no access to the data folders... –  Izzy Aug 23 '12 at 9:06
    
@Izzy TB has two backup methods. Its normal one stores three files in the backup directory - a tar.gz containing the APK, a tar.gz containing the contents of /data/data/[app]/, and a .properties file containing what I assume is a hash of the files. The other option (under "Send this Backup" -> "easy import" writes a single .TiBkp file that I believe contains the normal three. Either way, as you said, root access is required to restore the data to /data/data/[app]/ on the target device. –  Ian Renton Aug 23 '12 at 10:10
    
Yepp. The latter format is intended for easy transfer to e.g. another device (and thank me for mentioning this to the people from ES file explorer, that app now recognizes those files and offers to have them opened by TB, if installed). I was rather referring to the format of the (uncompressed) data packages (XML, SQLite, SQL...) to figure out how one could manipulate those -- and right in the middle remembered the target being non-rooted... Still, it could be an interesting idea for a "customized transfer" to another rooted target. –  Izzy Aug 23 '12 at 10:59

2 Answers 2

up vote 2 down vote accepted

Having now read more about the APK file format, I think I can now safely answer my own question with "it's impossible".

An APK file does not contain a data structure which is "unpacked" on install like the packages used by, for example, most Linux distributions. Instead, an APK is simply a self-contained, rebadged JAR file that contains the application's bytecode, manifest and certificate and nothing else.

The contents of /data/data/[appname] are presumably created by the application code when it is first run (or at some future point), and there is no way of embedding such data into an APK so that the system automatically moves it to the correct destination at install time.

share|improve this answer
    
It's not true that an APK only contains the bytecode, manifest, and certificate. It also contains any resources and assets used by the app, but they remain in the APK file when the app is installed: they're not copied to /data/data/ unless the app is programmed to do that itself. –  Dan Hulme Apr 26 at 9:44

You can still get the APK of an app with applications like ES File Explorer, AppMonster or Titanium Backup. But I don't know if they back up datas when the APK is built.

share|improve this answer
    
Non-root apps hardly can include data. AppMonster for sure does not -- and as for Titanium, the OP already stated it doesn't fit his needs. For ES I doubt it extracts data. –  Izzy Aug 23 '12 at 9:03
    
I have just tried ES, and it doesn't appear to include data with its backup either. (Or at least, when the backed up APK is installed on my non-rooted target device, the data I expect is not there.) As far as I can tell, ES' backup does nothing more than copy an APK from /data/apps to /sdcard/backups. –  Ian Renton Aug 23 '12 at 10:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.