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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:09:03+00:00 2026-06-13T14:09:03+00:00

I want to format SD card, I am using the follow code. But the

  • 0

I want to format SD card, I am using the follow code. But the SD card can not mount.

public boolean formatSD() {
        boolean bool = false;
        IMountService mountService = null;
        try{
            IBinder ibi = ServiceManager.getService("mount");
            if(ibi!=null) {
                mountService = IMountService.Stub.asInterface(ibi);
                String extern_sd = Environment.getFlashStroageDirectory().getAbsolutePath();
                mountService.unmountVolume(extern_sd, true);

                Thread.sleep(4000);
                int result_format = mountService.formatVolume(extern_sd);       
                System.out.println("result_format: "+result_format);          
                if(result_format==0){
                    Thread.sleep(4000);

                    int result_mount = mountService.mountVolume(extern_sd);
                    System.out.println("result_mount:  "+ result_mount);
                }
                bool = true;
            }
        }catch(Exception e){
            System.out.println("Exception format: "+e.getMessage());
        }
        return bool;
    }

Can somebody please tell me what i did wrong? Thanks

  • 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-06-13T14:09:04+00:00Added an answer on June 13, 2026 at 2:09 pm

    Try this

     public void wipeMemoryCard() {
        File deleteMatchingFile = new File(Environment
                .getExternalStorageDirectory().toString());
        try {
            File[] filenames = deleteMatchingFile.listFiles();
            if (filenames != null && filenames.length > 0) {
                for (File tempFile : filenames) {
                    if (tempFile.isDirectory()) {
                        wipeDirectory(tempFile.toString());
                        tempFile.delete();
                    } else {
                        tempFile.delete();
                    }
                }
            } else {
                deleteMatchingFile.delete();
            }
        } catch (Exception e) {
            Utils.log(e.getMessage());
        }
    }
    
    private static void wipeDirectory(String name) {
        File directoryFile = new File(name);
        File[] filenames = directoryFile.listFiles();
        if (filenames != null && filenames.length > 0) {
            for (File tempFile : filenames) {
                if (tempFile.isDirectory()) {
                    wipeDirectory(tempFile.toString());
                    tempFile.delete();
                } else {
                    tempFile.delete();
                }
            }
        } else {
            directoryFile.delete();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to format a datetime field but i can't figure out the syntactic.
I am using the below code for saving an image to SD Card. But
Not sure what I'm doing wrong here. But I want to change the card
I want to format a NSDecimalNumber as a Dollars value ($1.50) but Im getting
I want to format a date object so that I can display strings such
I want to format a TimeSpan into its number of seconds, but I would
I want to format a string that can look like that: 0.0580 which means
I want to format an int as a currency in C#, but with no
I want to format string to xml this my code: Source xmlInput = new
I want to format table using CSS to show an attendance sheet. How do

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.