How can I create an app which deletes itself? - java

How can i write a function that can remotely self-destruct it, ie delete that application from the phone?
Intent intent = new Intent(Intent.ACTION_DELETE);
intent.setData(Uri.parse("package:com.example.myapplication"));
startActivity(intent);
This code does not work on Android 10+

You can purge application files by enumerating app directory and deleting everything in there plus removing your application files on SD card. Uninstalling application itself is a different beast altogether. Non system apps cannot do that AFAIK (starting from android 2.0?).

Related

Uninstall APP using its APK

I need to trigger an uninstall of a certain app from within my own app. The only thing i have is the apps apk, even tho it doesn't have to be the same version as the installed app.
The uninstall would be handled by android of course. Just like installing an app from a given apk file.
Is there a way how i can put together an intent to make android open the responsible system service and and ask the user to uninstall or something like that?
The app to be uninstalled can change, so i can't use a constant packagename or something like that.
Is there some way to do this? I know you can extract the packagename from an apk, but it seems like a lot of work and probably overkill.
Using Intent.ACTION_DELETE intent
Intent intent = new Intent(Intent.ACTION_DELETE);
intent.setData(Uri.parse("package:com.example.mypackage"));
startActivity(intent);
You can get your own package name from context;
getApplicationContext().getPackageName();

Lost debug.keystore, can I update the Android app or retrieve the app data?

We have an internally deployed company app that has been signed with a developer's debug.keystore. The debug.keystore has been lost. Is there any possible way to:
Update a copy of the app using a new debug key.
Failing 1, is there any way an app with a new debug key could access the data of the already installed app (e.g. extract the data somehow, install the old and new apps side-by-side, adb uninstall -k)? The app does not have the debuggable flag set in its manifest.
I know the above is unlikely but I wanted to confirm before considering options as most stories about this concern Android market apps.
Looks like there's no way around this.

How to programmatically access installer service in android?

I have struck an idea of creating an app that automatically installs all the .apk packages placed inside a particular folder. In context to this, I want to learn how do I programmatically access installer service ?
Please enlighten me in this regard.
Your best bet would be to set an intent with type application/vnd.android.package-archive and then start installer activity:
Intent promptInstall = new Intent(Intent.ACTION_VIEW)
.setDataAndType(Uri.parse("file:///path/to/your.apk"),
"application/vnd.android.package-archive");
startActivity(promptInstall);
Check out Install Application programmatically on Android
Also, note, that for security reasons, you cannot install an apk 'silently' or automatically without user agreement. Therefore, the best you can do is like above.

Access SQLite DB without the emulator?

I have been trying to pull out my SQLite database from my android application onto my computer.
I only get results, when I run my application on the eclipse android emulator and then I can access to the DB. But the thing is using the emulator is to slow and it doesn't have all the data I have been storing on my app on the cellphone.
I have been googling that for a day and all I can see is "use the emulator".
Isn't it possible without the emulator ?
On commercially released Android devices, you aren't allowed access to your app's internal SQLite database (for security reasons). Thus, if you simply can't stand the emulator, or if you just want to test your app on an actual device to make sure it works properly, there are two options to consider.
Root your device. This will give you access to the /data folder where your app's internal SQLite database is stored.
Use a 3rd party library to write the contents of your database to the SD card. This is a nice workaround if you don't want to bother rooting your device. Check this post for one such implementation.
The SQLite database in your app is just a file. You can use the DDMS file view in Eclipse to pull the file off your device, but only if you have a rooted or development device, or if you're using the emulator.
Once youve got the file on your computer you'll be able to run queries against it using the sqlite3 command (which, depending on your system, you may have to install).

Automatically update Android App on Tablet (i.e. without Market!)

I've written an Android App which is primarily targeted to Android Tablets without the Market installed, which means the user cannot easily update the App. My idea is to download the apk file and do whatever the MArket is doing with the apk file.
As the app is preinstalled on the Tablets there is no restriction in Permissions, but the device must not to be rooted.
Seems the following code allows the user to install the apk after detecting a new version and downloading the apk file:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
startActivity(intent);
well i think that you just can do something like these. Verify version if version is lower app don't run.

Categories