0 votes
by (260 points)

Dear Pico Dev Support Team,
i would love to know what the path for the external sd card is.
I am using the unreal engine 4.27 to make an app that compares different files on the internal memory (which i already have access to) with files on the external sd card (which i don't have access to) as well as read files from the external sd card.
The sd card is being switched regulary, as the content is too large to store it on the device itself.

I tried creating .txt files with a multitude of paths (/storage/ | /mnt/sdcard/ | /mnt/external_sd/ | /storage/self/ | /storage/xxxx-xxxx/) with no luck. I am using a blueprint function to write the txt file, which works flawlessly on the /sdcard/ (so the permissions are good).

Is there a custom path for the sd card? (the sd card cannot be mounted as internal, as it needs to be switched a lot)

Thank you in advance!
With kind regards,
Max

1 Answer

+1 vote
by (6.5k points)
selected by
 
Best answer

Pico G2 4K should be no different from other Android 8.1 devices regarding this usage. It needs to obtain the SD card path through the Android interface and call it in UE4.You can refer to these links:
How to get the external sd card path on android:
https://gist.github.com/PauloLuan/4bcecc086095bce28e22?permalink_comment_id=2591001#gistcomment-2591001
How to use android in UE4:
https://forums.unrealengine.com/t/how-to-use-android-aar-or-jar-library-in-unreal-engine-4/103416/3

by (260 points)

Thank you. The direction was correct.

For anyone with the same problem, here is a rough summary.

Get the JNI Unreal Plugin at

https://github.com/Sovahero/PluginMobileNativeCode

follow the instructions. There are multiple examples that show how it works. You can add either a new java file with your own class, or you can implement the function in one of the working examples (ignore the class in the following code, if u prefer the second solution).

The Java Code that works on the Pico G24K is:

package com.Plugins.MobileNativeCode;
import android.os.Environment;
import androidx.annotation.Keep;
import java.io.File;


@Keep
public class SDInfo {

@Keep
    public static String getSDPath() {

    String removableStoragePath = "none";

     File fileList[] = new File("/storage/").listFiles();
         for (File file : fileList)
      {     if(!file.getAbsolutePath().equalsIgnoreCase(Environment.getExternalStorageDirectory().getAbsolutePath()) && file.isDirectory() && file.canRead())
            removableStoragePath = file.getAbsolutePath();  }

    return removableStoragePath;
    }
}

You will get the sd card path with the c++ call :


FString sdPath;
sdPath += AndroidUtils::CallJavaCode<FString>("com/Plugins/MobileNativeCode/SDInfo", "getSDPath", "", false);

I can confirm that it works with UE4.27 and the Pico G24K (tested with different sd cards).

Cheers!
Max

...