Skip to content

Instantly share code, notes, and snippets.

@xorrizon
Created February 5, 2013 21:16
Show Gist options
  • Save xorrizon/4717734 to your computer and use it in GitHub Desktop.
Save xorrizon/4717734 to your computer and use it in GitHub Desktop.
A little uninstall script I wrote to uninstall android apps via adb
#!/usr/bin/env ruby
def get_packages(prefix)
pkgs = []
s = `adb shell pm list packages #{prefix}`
s.each_line do |line|
next unless line.start_with?("package:")
pkgs << line.split(":")[1]
end
pkgs
end
def uninstall_package(pkg)
`adb uninstall #{pkg}`
end
def usage
puts "USAGE: #{__FILE__} package"
puts "Example: #{__FILE__} org.catrobat"
end
if ARGV.length < 1
puts usage
exit 1
end
pkgs = get_packages(ARGV[0])
pkgs.each do |pkg|
print "uninstalling " + pkg
puts uninstall_package(pkg)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment