I wrote a Beta version of the application. It will be available for download through the web (I will not publish it to the Play Market). Is it possible to update this application without Play Market visit when the new version will be released?
-
yes it is possible. Outside of that, what have you tried? and how in depth do you want it to go? auto update download and install? or open browser download and install? – Eluvatar Mar 04 '13 at 23:48
-
Thanks for your answer, but Blumer have already gave me an answer with example of code. I think for my case it's enough. Thanks again) – IQW Mar 04 '13 at 23:57
-
@IQW Can you please show the code what did you try because I have the same problem I need to check from a domain there I have uploaded my apk and to check if there is new version or not ? – TheCoderGuy Apr 09 '19 at 18:05
5 Answers
Absolutely. You will need to build a mechanism, though, for your app to call home to the server, find out if there's a newer version of the app, and if there is, pull it down and install it. Once you've determined that you do need to pull down an update, you can do that with something similar to this AsyncTask:
protected String doInBackground(String... sUrl) {
String path = "/sdcard/YourApp.apk";
try {
URL url = new URL(sUrl[0]);
URLConnection connection = url.openConnection();
connection.connect();
int fileLength = connection.getContentLength();
// download the file
InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream(path);
byte data[] = new byte[1024];
long total = 0;
int count;
while ((count = input.read(data)) != -1) {
total += count;
publishProgress((int) (total * 100 / fileLength));
output.write(data, 0, count);
}
output.flush();
output.close();
input.close();
} catch (Exception e) {
Log.e("YourApp", "Well that didn't work out so well...");
Log.e("YourApp", e.getMessage());
}
return path;
}
// begin the installation by opening the resulting file
@Override
protected void onPostExecute(String path) {
Intent i = new Intent();
i.setAction(Intent.ACTION_VIEW);
i.setDataAndType(Uri.fromFile(new File(path)), "application/vnd.android.package-archive" );
Log.d("Lofting", "About to install new .apk");
this.context.startActivity(i);
}

- 5,005
- 2
- 33
- 47
-
1Question: What happens with "publishProgress((int) (total * 100 / fileLength));"? Where will this Methode be called and what is it doing? Thanks in advance. – KingAlex1985 Jul 10 '14 at 08:19
-
-
1A few points to consider if you use this solution: 1) yes it must be external storage - internal is not shared between apps and is not visible to "installation app" 2) you can't use content provider because this is not supported by "installation app" (needs to be file://...) and 3) you probably want to use `Environment.getExternalStorageDirectory()` instead of hardcoded path. Otherwise this solution works, thanks! – johndodo Jul 18 '16 at 10:40
-
6Can I suppress the user prompt if no extra permissions are being sought ? – Jaydev Nov 05 '16 at 08:23
-
This is not working in Android N, can you suggest any other answer which is working in Android N too. – Manikanta Ottiprolu Jan 11 '17 at 11:23
-
1For Android N I had to add File Provider or Strict mode: https://stackoverflow.com/questions/38200282/android-os-fileuriexposedexception-file-storage-emulated-0-test-txt-exposed – JoKr Jul 15 '17 at 13:22
-
Using this code in my app. The app is being downloaded and installed successfully but as I open again, It gives error popup as `There was a problem parsing the package`. Please help me out here https://stackoverflow.com/questions/48313766/getting-error-pop-up-after-installation-of-android-app – Shambhu Jan 18 '18 at 04:41
-
-
@Blumer Can you please see my question ? https://stackoverflow.com/questions/55587654/how-to-check-from-a-web-if-the-versionname-of-apk-with-the-installed-apk-at-devi – TheCoderGuy Apr 09 '19 at 17:57
-
And as what is the `publishProgress` declared because I used this code but the`publishProgress` is not declared ? And it is the same with the `@Override` does not override method from its superclass – TheCoderGuy Apr 09 '19 at 18:09
-
@stephanlindauer it won't be deleted but if you want to delete it after installation then it should come below this line: this.context.startActivity(i); File apkFile = new File("/sdcard/YourApp.apk"); if(apkFile.exists) {apkFile.delete;} – chisom emmanuel Sep 21 '22 at 18:48
Yes it is possible, here is roughly what you can do:
Get the current application versionCode
PackageInfo packageInfo = getPackageManager().getPackageInfo(context.getPackageName(), 0); int curVersionCode = packageInfo.versionCode;
Have a server where you host the apk file and create a simple plain file containing only one integer, which represents the latest application version code.
When the app starts (or whenever you want to check for an update), retrieve the latest versionCode from the server (i.e via an HTTP request) and compare it with the current app version.
If there is a new version, download the apk and install it (will prompt a dialog for the user).
Edit:
You can use the code of @Blumer for this.

- 22,334
- 15
- 80
- 130

- 18,192
- 4
- 57
- 80
-
Using Blumer's code in my app. The app is being downloaded and installed successfully but as I open again, It gives error popup as `There was a problem parsing the package`. Please help me out here https://stackoverflow.com/questions/48313766/getting-error-pop-up-after-installation-of-android-app – Shambhu Jan 18 '18 at 04:44
it is possible, however keep in mind that the user will have to have "Allow installation of non-Market-applications/unknown sources" enabled in their settings.

- 1,910
- 2
- 14
- 17
-
Have you got an idea what happens if above setting disabled at the time of uploading the app. – chandimak Jun 23 '15 at 19:16
-
uploading to where? the market? its a setting on the device not in the binaries or the market. this is what i mean: http://www.tech-recipes.com/wp-content/uploads/Screenshot_2012-03-18-16-55-37.png – stephanlindauer Jun 23 '15 at 21:14
-
Sorry. Misspelled. I wanted to say 'updating' not 'uploading'. So, when there's an update to the app and at that time the status of the above setting is 'disable' what would happen. Does it automatically allow updating or user explicitly need to set above setting 'enable' again. – chandimak Jun 24 '15 at 06:17
-
1as far as i can remember: you would be able to download the apk but you wouldnt be able to install it. but its worth checking the current state of affairs. i think google wanted to completely ban those self initiated updates. – stephanlindauer Jun 25 '15 at 20:07
-
On Oreo (Possibly older versions too) if you don't have that permission set the OS will tell you this is required and take you to the appropriate setting. You can configure from there the list of apps that can install from unknown sources - The user will need to set your app to allow this – Dan Harris Apr 13 '18 at 16:29
FYI, i just read about this at http://blog.vivekpanyam.com/evolve-seamlessly-deploy-android-apps-to-users/?hn
Evolve is a library for Android Developers that lets them deploy new versions of an app without going through Google Play or asking users to download an update. It works by using reflection and dynamic bytecode generation to "trick" Android into running new code.
Its alpha though, but it seems possible via a lot of hoops. I doubt if its worthwhile except for malicious software..

- 3,890
- 4
- 24
- 30
Official support/library for In-app updates Google play core
- In-app updates is a Play Core library feature that prompts active users to update your app. The in-app updates feature is supported on devices running Android 5.0 (API level 21) or higher, and requires your app to use Play Core library version 1.5.0 or higher. Additionally, in-app updates are only supported for Android mobile devices, Android tablets, and Chrome OS devices.
Below are type of Update flows
- Flexible updates (Sample screen)
- Immediate updates (Sample screen)

- 2,457
- 2
- 21
- 38