Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6973765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:09:01+00:00 2026-05-27T17:09:01+00:00

I am trying to install apk programmatically from SD card without mentioning the name

  • 0

I am trying to install apk programmatically from SD card without mentioning the name of the apk. What I can do now is I can get installed the apk I named in my code. But it is not handy if I want to have another apk installed on my device and for that I have to go into my code and change the name of the apk. Is there any way to get the name of the apk file dynamically on run time? For instance getting a list of installable apk, so that user can choose which one to install?

Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(
Uri.parse("file:///mnt/sdcard/extsd/download   /app.apk"),
"application/vnd.android.package-archive");
startActivity(intent);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:09:02+00:00Added an answer on May 27, 2026 at 5:09 pm

    Update: The previous code was deleted because contain errors. Here is a working code:

    public class InstallAPKActivity extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            ExtFilter apkFilter = new ExtFilter("apk");
            File file[] = Environment.getExternalStorageDirectory().listFiles(apkFilter);
            Log.d("InstallApk", "Filter applied. Size: "+ file.length);
    
            for (int i=0; i < file.length; i++)
            {
                Log.d("InstallApk", "FileName:" + file[i].getName());
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setDataAndType(Uri.fromFile(file[i]), "application/vnd.android.package-archive");
                startActivity(intent);
            }
    
    
    
    
    
        }
    
        class ExtFilter implements FilenameFilter { 
            String ext; 
            public ExtFilter(String ext) { 
                this.ext = "." + ext; 
            } 
            public boolean accept(File dir, String name) { 
                return name.endsWith(ext); 
            }
        }
    }
    

    Update 2:
    This program simply enumerates all apk file and writes them to the array of File. After that it tries to install all this apk files sequentially. For instance, in my case I put application golddream.apk on a sdcard of my emulator. The application is developed for SDK v 10. I see the following output in my logcat:

    12-21 06:44:39.453: D/InstallApk(14897): Filter applied. Size: 1
    12-21 06:44:39.453: D/InstallApk(14897): FileName:golddream.apk
    12-21 06:44:39.463: I/ActivityManager(62): Starting: Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/golddream.apk typ=application/vnd.android.package-archive cmp=com.android.packageinstaller/.PackageInstallerActivity } from pid 14897
    12-21 06:44:40.073: I/ActivityManager(62): Displayed com.android.packageinstaller/.PackageInstallerActivity: +578ms (total +1s229ms)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made code that download APK from ftp, and I`m trying to install it
I`am trying to download and install an apk from some link, but for some
I've been trying to get an android application to install an APK on the
I have downloaded the Layar401.apk file from web and trying to install it into
When trying to install the mysql gem from cPanel on my website, I get
While trying to install a program from source I found that it installed libraries
Trying to install pear package and keep getting this strange error. Can you shed
I'm trying to install some Ruby Gems so I can use Ruby to notify
I am trying to install the ibm_db gem so that I can access DB2
Trying to install mysql-python. Got following error. Got mysql and pythond already installed. Any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.