I have a .apk file of a library project, now i want to use that .apk file in my application project(in assets folder) and while running my application project i want to put a .sql file into that .apk file and when i click on one button then i want to store that .apk in external sd card along with that .sql file. Is it possible to do that?
Asked
Active
Viewed 213 times
2 Answers
0
apk is compressed format,so may be you can check how to pack and unpack data from apk.

Iftikar Urrhman Khan
- 1,131
- 1
- 10
- 21
-
Thank you for your quick reply..Can you please send me some related links for pack and unpack data from .apk ? @ lftikar Urrhman Khan – Shylendra May 14 '13 at 04:46
-
take a look at java.util.zip may be this can help. [link](http://stackoverflow.com/questions/7485114/how-to-zip-and-unzip-the-files) – Iftikar Urrhman Khan May 14 '13 at 04:53
-
By using this link i tried for zipping a folder, i got a zip file but when i open it nothing in that it showing error like "The archive is either in unknown format or damaged" – Shylendra May 16 '13 at 03:48
0
I got by using bellow code:
private void onGenButtonClickListener() {
Button generatebutton = (Button) findViewById(R.id.sign_apk);
generatebutton .setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
generateAPK();
}
});
}
private void generateAPK() {
try {
String generatedApkPath = GENERATE_APK_TO_DIRECTORY + apkname + ".apk";
String signedApkPath = GENERATE_APK_TO_DIRECTORY + apkname + "-signed.apk";
Log.i("Sign APK", "Going to create signed apk in:" + signedApkPath);
ZipSigner zipSigner = null;
zipSigner = new ZipSigner();
zipSigner.setKeymode("testkey");
zipSigner.signZip(generatedApkPath, signedApkPath);
// After signing apk , delete unsigned apk
new File(generatedApkPath).delete();
Toast.makeText(getApplicationContext(),
"'" + apkname + "-signed.apk' is generated at " + GENERATE_APK_TO_DIRECTORY, Toast.LENGTH_LONG)
.show();
} catch (Throwable t) {
Log.e("Signing apk", "Error while signing apk to external directory", t);
t.printStackTrace();
}
}

Shylendra
- 69
- 1
- 7