How do I uninstall and re-run an app on a device using Android Studio?
You can skip the force stop and uninstall step by just hitting run
again. Android Studio should prompt you which device to run on and there you can select your connected device.
It will close the app and re-run your changed version.
How to automatically uninstall android app from device before installing a new version
Apparently, if you in Run -> Edit Configurations...
, on the left side there is a expendable list of Android configurations.
Select yours, on the right side of the window are details on the configuration, at the bottom of that section is the Before launch
section.
Create a gradle-aware Make
, given the task :app:uninstallAll
or :app:uninstallDebug
whichever suits you. (There is autocompletion to get all the available tasks, app
may vary if you have several modules).
Automatically uninstalling the older app before installing the new one
No, there is no way to force uninstallation before installation. But it sounds like you could just delete your DB on upgrade using SQLiteOpenHelper
Android Studio : How to uninstall APK (or execute adb command) automatically before Run or Debug?
adb uninstall <package_name>
can be used to uninstall an app via your PC. If you want this to happen automatically every time you launch your app via Android Studio, you can do this:
- In Android Studio, click the drop down list to the left of Run button, and select Edit configurations...
- Click on app under Android Application, and in General Tab, find the heading 'Before Launch'
- Click the + button, select Run external tool, click the + button in the popup window.
- Give some name (Eg adb uninstall) and description, and type
adb
in Program: anduninstall <your-package-name>
in Parameters:.
Make sure that the new item is selected when you click Ok in the popup window.
Note: If you do not have adb in your PATH environment variable, give the full path to adb in Program: field (eg /home/user/android/sdk/platform-tools/adb).
Require users to uninstall previous Android app version on update
As far as I know, there is no way to do exactly what you asked for. But, if there are only database changes, you can just rename the database file to make your application to start using a new database file and ignore the old one.
Example:
// in your DatabaseHelper constructor
private DatabaseHelper(Context context) {
super(context, "new_database.db", null, DB_VERSION);
}
Related Topics
How to Insert Image in a SQLite Database
Google Play App Description Formatting
Understanding Canvas and Surface Concepts
Alternatives to Preferencefragment with Android-Support-V4
How to Test If a Fragment View Is Visible to the User
How to Remove the Top and Bottom Space on Textview of Android
Android Splash Screen Sizes for Ldpi,Mdpi, Hdpi, Xhdpi Displays? - Eg:1024X768 Pixels for Ldpi
Allow Multi-Line in Edittext View in Android
How to Set Google Map Fragment Inside Scroll View
Illegalstateexception When Replacing a Fragment
Pass List of Objects from One Activity to Other Activity in Android
" App-Release.Apk" How to Change This Default Generated APK Name
How to Record Video from Background of Application:Android
How to Get Charles Proxy Work with Android 7 Nougat
Multiple Mime Types in Android