Skip to content Skip to sidebar Skip to footer

Unable To Create File On Removeable Sdcard In Android 5.0.1

I am working on an application that needs the ability to create files on the removable sd card in the Samsung S4 i9295 device. I am running a stock Samsung ROM 5.0.1 that has been

Solution 1:

Got it. In general, replacing...

StringszFilePath="/mnt/extSdCard/temp";

with this:

File[] fo = getExternalFilesDirs(null);
    Filef=fo[1];

has resolved the issue. Specific changes to final test case are:

publicvoidcreateRemoveableSdcardFile(View view) {
    File[] fo = getExternalFilesDirs(null);
    Filef=fo[1];
    FileappDir=newFile(f, "TargetFile");
    appDir.mkdir();  
    makeTimestamp();
    FileexportDir=newFile(f, "TargetFile/" + szDateTime);
    exportDir.mkdir();         
}

This creates a file on the removeable sdcard here:

../extsdcard/android/data/net.google.example/file/

Post a Comment for "Unable To Create File On Removeable Sdcard In Android 5.0.1"