Tech Blog

Android, Coding, Programming, Software

How to extract APK file of installed application in Android programmatically

By Sushant Singh Rathore1 min read
← Back to blog

Step 1 : Get the path of the installed application

// package name of application whose apk you want to extract 
String lStrPackageName = "com.yourapp.packagename";
String lStrApplicationPath = context.getPackageManager()
  .getPackageInfo(lStrPackageName, 0).applicationInfo.publicSourceDir;

Step 2 : Store the Apk file in required folder

//Provide the source path of application
String lStrSourcePath = lStrApplicationPath;
File lObjSource = new File(lStrSourcePath);
//Provide destination path where you want to save APK file
String lStrFinalPath = "/sdcard/YourAppName.apk";
File lObjDestination = new File(lStrFinalPath);
//copy the apk file to required folder
try
{
   FileUtils.copy(new FileInputStream(lObjSource), new FileOutputStream(lObjDestination));
}
catch (IOException e)
{
   e.printStackTrace();
}

Keep reading

You may be interested in

Browse all articles →
Useful Shortcut to Speed up Android Development
March 18, 20223 min read

Useful Shortcut to Speed up Android Development

Developing Android Application as an Android Developer requires a lot of things out of which writing code & navigating through code is an important aspect . So while doing that you can use a bunch of shorthand tricks that will help you speed up your development process. 1. Recent File List : Ctrl + E (in Windows) […]

By Sushant Singh RathoreRead More →
How Angular is Different from AngularJS
September 27, 20227 min read

How Angular is Different from AngularJS

What is Angular? Angular is a popular open-source Typescript framework and free to use. Considered to be a JavaScript-based framework,TypeScript.is its primary programming language. TypeScript is Developed by Microsoft and its superset of JavaScript, which simply means that TypeScript has all the capabilities that JS has and more additional features. Angular is majorly used for […]

By Sachin DevadigaRead More →
Angular constructor vs ngOnInit
September 15, 20223 min read

Angular constructor vs ngOnInit

Overview: If you are new to angular or have been working with it for a while, you will have questions like: Is it necessary to inject dependencies in the constructor and bind data? When should we use ngOnInit ? What is the difference between constructor and OnInit?. So, in this blog we will answer all […]

By Priyanka SRead More →