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 6250433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:25:21+00:00 2026-05-24T13:25:21+00:00

I have an android application that scans the sd-card and plays file that are

  • 0

I have an android application that scans the sd-card and plays file that are located on the sd-card. however, i want to first check whether sd-card is in the slot or not before i can continue processing. however, the alert dialog doesn’t wait for the input and continue processing the background which gives errors because there is no sd-card and the background processing tries to access that sd-card. I want to wait until I am finished with the alert dialog. is there any way of doing this?? Here is the code for the alert dialog. I just want the program to wait until the user selects the option..

String state = Environment.getExternalStorageState();
    if (state.equalsIgnoreCase("mounted"))
    {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage("The SD Card has been removed from your device. Please re-insert the SD card and try again")
       .setCancelable(false)
       .setPositiveButton("Retry", new DialogInterface.OnClickListener() {
           @Override
           public void onClick(DialogInterface dialog, int id) 

           {

              onRecreate();

           }
       })
       .setNegativeButton("Exit", new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int id) 
           {
               dialog.cancel();
             //  onDestroy();
               finish(); 
           }
       })

       .setTitle("No SD-card Found")
       .setIcon(R.drawable.alert_dialog_icon_m);
        AlertDialog alert = builder.create();
        alert.show();   

    return 0;
    }//IF condition closes   
    else
    return 1;
  • 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-24T13:25:22+00:00Added an answer on May 24, 2026 at 1:25 pm

    Simply don’t do anything until the user presses one of the dialog’s buttons. Since there is not much you can do if the SD card is not mounted, just have a ‘Please mount SD card to continue’ and an ‘OK’ button that finish()-es the activity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Android application that writes data to the SD card. I want
I want to build an notepad-style application on android that will have syntax highlighting.
I have an android application that I want to always be running in landscape
I have an Android application that connects to Facebook to request authorization of an
I have a Web Service and an Android application that uses this web service.
I want to integrate the zxing source code to my Android application. I have
I have an android application that hits the WebView and displays the content. But
I have an android application that starts an activity and is running well. I
I have an Android application that I've been working on, and it's implemented using
I have an Android application that is a TabHost with a WebView. I use

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.