0

I want to use the sdcard as a storage support of my application's data, the problem I encountered the path varies depending on the manufacturer, I do not have the same configuration for all tablets. I used the code below.

File root = Environment.getExternalStorageDirectory();
            String Path =  root.getAbsolutePath().toString();
            File mFile = new File(Path+ "/fileName");
            if(mFile.exists()){
                mFile.delete();  
            }

With some tablets the job is done and the file is deleted with other no. So can you tell me how to get the external storage for all tablets.

Zizou
  • 1,891
  • 3
  • 15
  • 16
  • this can probably help you : http://stackoverflow.com/questions/10629523/building-a-utility-to-get-the-path-to-external-removable-storage-every-time –  Jun 11 '13 at 15:23

1 Answers1

1

File has a constructor that takes two parameters. A file and a String.

File root = Environment.getExternalStorageDirectory();
File mFile = new File(root, "fileName");
if(mFile.exists()){
    mFile.delete();  
}
Blackbelt
  • 156,034
  • 29
  • 297
  • 305