i have retrieve all apk installed in my device and I created a list in which I can see them. On click over an item, I have created a dialog.I would that on positive button copy the apk of that position in a folder I created in the sdcard. So far I tried and I can show in a toast the app folder and position of each apk but I don't understand how can I copy that apk I have selected. This is the code
.setPositiveButton("Copy apk", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogapk, int id)
{
// TODO: Implement this method
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List pkapplist = getActivity().getPackageManager().queryIntentActivities(mainIntent, 0);
for (Object o : pkapplist) {
ResolveInfo info = (ResolveInfo) o;
file = new File( info.activityInfo.applicationInfo.publicSourceDir);
Toast.makeText(getActivity(), "Boh "+file, Toast.LENGTH_SHORT).show();
}
try
{
process = Runtime.getRuntime().exec("cp " + file + " " + customfolder);
}
catch (IOException e)
{
}
}
});
Custom folder is the folder I have created in this way
final File customfolder = new File(Environment.getExternalStorageDirectory().toString()+File.separator+"BackupApk");
Actually it creates a file and not a folder of size of application itself..I don't know exactly what it is doing!! Thanks. If needs the adapter let me know