Question

I know of two ways of deleting an app under development from the emulator:

  1. Using the emulator GUI: Settings > Applications > Manage Applications > Uninstall
  2. Using ADB: adb uninstall

I may have discovered a third way, using 'adb shell':

rm /data/app/<package>.apk

It seems, however, that this isn't really a good way to delete apps because there may be additional information associated with it (registration?).

What is that information and where can it be found?

Was it helpful?

Solution

It's interesting you mention this. I ran a quick home made test to shed some light onto your question.

Generally, when you install a .apk file, Android creates an internal storage area for it located at /data/data/< package name of launching activity>. This is mainly used as an internal caching area that cant be accessed by other apps or the phone user. You can read up about that in a little bit more detail in the Internal storage chapter of Androids data storage section. It is an area exclusively used by your app and you can write private data there.

Once you uninstall an app theoretically, this internal storage area is also deleted. The first 2 ways which you outlined indeed does that: the .apk file in /data/app/ is deleted aswell as the internal storage area in /data/data/.

However if you used adb shell and run the rm command, all that is removed is the .apk file in /data/app/. The internal storage area in in /data/data/ is not deleted. So in essence you are correct that additional information with the app is not necessarily deleted. But on the flip side, if you reinstall the app after running the command, then the existing internal storage area gets overwritten as a fresh copy of it is being installed.

OTHER TIPS

I was having a problem with this too. I have Link2SD on my phone, but the ext4 partition on my SD card corrupted, so I reformatted, but all of the linked files were still in the /data/app folder. So I created a script to delete all broken links, and ran into the same problem as you, the app manager said they were still installed! so I made another script to fix that, using the pm program on your phone.

heres my code to remove broken links from the app folder:

fixln.sh

#!/system/bin/sh
#follow and fix symlinks

appfolder="/data/app/"
files=`ls ${appfolder}*`
fix=$1
badstring="No such file or directory"
for i in $files
do
    if [ -h $i ]
    then
        if [ -a `readlink $i` ]
        then
            echo -e "\e[32m$i is good\033[0m";
        else
            if [ $fix == "fix" ]
            then
                `rm $i`
                echo -e "\e[31m$i is bad, and was removed\033[0m";
            else
                echo -e "\e[31m$i is bad\033[0m";
            if
        fi
    else
        echo -e "\e[36m$i is not a symlink\033[0m";
    fi
done

and heres my code to uninstall apps that have no apk:

fixmissing.sh

#!/system/bin/sh
#searches through a list of installed apps, and removes the ones that have no apk file

appfolder="/data/app/"
fix=$1

installed=`pm list packages -f -u`

for i in $installed
do
    usefull=${i#*:}
    filename=${usefull%=*}
    package=${usefull#*=}

    if [ -a $filename ]
    then
        echo -e "\e[32m$package ($filename) is good\033[0m"
    else
        if [ "$fix" == "fix" ]
        then
            uninstall=`pm uninstall $package`
            if [ "$uninstall" == "Success" ]
            then
                echo -e "\e[31m$package ($filename) is bad, and was removed\033[0m"
            else
                echo -e "\e[31m$package ($filename) is bad, and COULD NOT BE REMOVED\033[0m"
            fi
        else
            echo -e "\e[31m$package ($filename) is bad\033[0m"
        fi
    fi
done

copy these files to your phone, and run them with no arguments to see what they find, or add fix onto the end (fixmissing.sh fix) to make them fix what they find. Run at your own risk, and back up your files. I am not responsible if this code in any way wrecks anything.

If anyone wants to update/merge these scripts together, thats fine. these were just made to fix my problem, and they have done so, just thought I'd share them.

adb uninstall com.example.test

com.example.test may vary acording to your app.

I believe any files the app has created on the sdcard would not be deleted.

There is another way - using the emulator like a real device - locate the app in the emulator and drag it up to uninstall it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top