# UE4Game folder on External Storage -

**URL:** <https://forums.unrealengine.com/t/ue4game-folder-on-external-storage/368493>\
**Category:** Mobile\
**Tags:** folder, create, unreal-engine, Android, UE4, question\
**Created:** [August 28, 2016, 1:21am UTC](https://forums.unrealengine.com/t/ue4game-folder-on-external-storage/368493 "2016-08-28T01:21:00Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_1e03d513](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1e03d513](https://forums.unrealengine.com/u/anonymous_user_1e03d513)\
**Post date:** [August 28, 2016, 1:21am UTC](https://forums.unrealengine.com/t/ue4game-folder-on-external-storage/368493/1 "2016-08-28T01:21:00Z")

</div>

Hello UE Team, I wanted to know whether it’s possible to prevent a ue4 game to create a folder (UE4Game and its content) automatically in External storage? I want to have it on internal data folder (like /data/com. **.** /UE4Game/) so the user can’t see the save games easily (e.g)

---

<div class="post-metadata">

**Author:** ![wingedrobin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@wingedrobin](https://forums.unrealengine.com/u/wingedrobin)\
**Post date:** [September 14, 2016, 4:59am UTC](https://forums.unrealengine.com/t/ue4game-folder-on-external-storage/368493/2 "2016-09-14T04:59:10Z")

</div>

Same question. Another pain is that when app was uninstalled, the UE4Game folder will not be auto removed. I think that is a bad user experience. Why design this like that? Is there any pros or limitation?

I found a global variable **GFilePathBase** at line 865 in file \Engine\Source\Runtime\Launch\Private\AndroidJNI.cpp. It is assigned to ExternalStorageDirectory(/storage/sdcard0) of . And another global variable **GExternalFilePath** at line 926 is assigned to ExternalFilesDir(/storage/sdcard0//data/package/files), I think this is what we looking for. But now I don’t have any idea to modify it to suit this purpose. Maybe someone else has any idea or experience?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1e03d513](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1e03d513](https://forums.unrealengine.com/u/anonymous_user_1e03d513)\
**Post date:** [September 16, 2016, 10:35pm UTC](https://forums.unrealengine.com/t/ue4game-folder-on-external-storage/368493/3 "2016-09-16T22:35:08Z")

</div>

I edited those variables. Now I’m trying to build the engine. Hoping for no errors 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1e03d513](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1e03d513](https://forums.unrealengine.com/u/anonymous_user_1e03d513)\
**Post date:** [September 19, 2016, 9:11pm UTC](https://forums.unrealengine.com/t/ue4game-folder-on-external-storage/368493/4 "2016-09-19T21:11:18Z")

</div>

Unsuccesful with building engine from source code \*\*for \*\*

---

<div class="post-metadata">

**Author:** ![darren\_mii](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@darren\_mii](https://forums.unrealengine.com/u/darren_mii)\
**Post date:** [October 10, 2016, 2:13pm UTC](https://forums.unrealengine.com/t/ue4game-folder-on-external-storage/368493/5 "2016-10-10T14:13:32Z")

</div>

Can someone from Epic please answer this

---

<div class="post-metadata">

**Author:** ![Chris\_Babcock](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chris\_Babcock](https://forums.unrealengine.com/u/Chris_Babcock)\
**Post date:** [October 19, 2016, 5:16pm UTC](https://forums.unrealengine.com/t/ue4game-folder-on-external-storage/368493/6 "2016-10-19T17:16:24Z")

</div>

Any files placed in GExternalFilePath will be cleaned up when the APK is uninstalled. You can make this change in AndroidJNI.cpp to ue4\_GameActivity\_nativeSetGlobalActivity after GExternalFilePath = FString(nativeExternalFilesPathString):

```
#if UE_BUILD_SHIPPING
GFilePathBase = GExternalFilePath;
#endif

```

This will use the external file path for shipping builds. You don’t want to do this for launch-on since it expects to find the pushed files in the normal location.

I am planning to provide this as a checkbox option in 4.15; the feature set for 4.14 is already locked down.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d263f0c4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d263f0c4](https://forums.unrealengine.com/u/anonymous_user_d263f0c4)\
**Post date:** [October 20, 2016, 6:31am UTC](https://forums.unrealengine.com/t/ue4game-folder-on-external-storage/368493/7 "2016-10-20T06:31:04Z")

</div>

After I did that, an error message showed up when I launched project on device.

 ![111663-screenshot_2016-10-20-14-28-52-398_com.yourcompany.newproject.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/3/9/1398359bb849e3b18656bc2ae5eee6489385e6e1.png)

How can I fix this?

Thx

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1e03d513](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1e03d513](https://forums.unrealengine.com/u/anonymous_user_1e03d513)\
**Post date:** [October 20, 2016, 2:26pm UTC](https://forums.unrealengine.com/t/ue4game-folder-on-external-storage/368493/8 "2016-10-20T14:26:03Z")

</div>

Ok, better I wait until version 4.15. I’m unsure while editing the source code, so I let the Epic developers do that.

---

<div class="post-metadata">

**Author:** ![Chris\_Babcock](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chris\_Babcock](https://forums.unrealengine.com/u/Chris_Babcock)\
**Post date:** [November 9, 2016, 11:31pm UTC](https://forums.unrealengine.com/t/ue4game-folder-on-external-storage/368493/9 "2016-11-09T23:31:35Z")

</div>

I believe you have an OBB outside of the APK and it is failing to mount it. There is a fix, but it involves a few more changes.

In AndroidFile.cpp:

add `FString GFileExternalStorage;` before

```
// External File Path base - setup during load
FString GFilePathBase;

```

Then change

```
FString OBBDir1 = GFilePathBase + FString(TEXT("//obb/") + GPackageName);
FString OBBDir2 = GFilePathBase + FString(TEXT("/obb/") + GPackageName);

```

to

```
	FString OBBDir1 = GFileExternalStorage + FString(TEXT("//obb/") + GPackageName);
	FString OBBDir2 = GFileExternalStorage + FString(TEXT("/obb/") + GPackageName);

```

In AndroidJNI.cpp:

add `extern FString GFileExternalStorage;` before `extern FString GFilePathBase;`

add '`GFileExternalStorage = GFilePathBase;` after `GFilePathBase = FString(nativePathString);` in JNI\_OnLoad().

Now it will still be able to access the OBB.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d263f0c4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d263f0c4](https://forums.unrealengine.com/u/anonymous_user_d263f0c4)\
**Post date:** [November 10, 2016, 4:22am UTC](https://forums.unrealengine.com/t/ue4game-folder-on-external-storage/368493/10 "2016-11-10T04:22:39Z")

</div>

It works!  
Thank you!

---

<div class="post-metadata">

**Author:** ![wingedrobin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@wingedrobin](https://forums.unrealengine.com/u/wingedrobin)\
**Post date:** [November 10, 2016, 5:02am UTC](https://forums.unrealengine.com/t/ue4game-folder-on-external-storage/368493/11 "2016-11-10T05:02:54Z")

</div>

Hi Chris, thanks for the solution. And I wanna confirm one thing that is this will certainly add into UE4 in version 4.15?

---

<div class="post-metadata">

**Author:** ![Chris\_Babcock](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chris\_Babcock](https://forums.unrealengine.com/u/Chris_Babcock)\
**Post date:** [November 15, 2016, 5:39pm UTC](https://forums.unrealengine.com/t/ue4game-folder-on-external-storage/368493/12 "2016-11-15T17:39:50Z")

</div>

Yes, it is a checkbox in 4.15.

---

<div class="post-metadata">

**Author:** ![yyartsworld](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@yyartsworld](https://forums.unrealengine.com/u/yyartsworld)\
**Post date:** [December 2, 2016, 5:05am UTC](https://forums.unrealengine.com/t/ue4game-folder-on-external-storage/368493/13 "2016-12-02T05:05:12Z")

</div>

There are serious problems.  
If user doesn’t have external sdcard, UE4Game folder is created in Internal storeage and It will not be removed when uninstall.  
And another problem is that All game resource images are shown in gallery app.

I hope these Problems will be fixed in 4.15

---

<div class="post-metadata">

**Author:** ![BPSailor](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BPSailor](https://forums.unrealengine.com/u/BPSailor)\
**Post date:** [March 15, 2017, 9:08am UTC](https://forums.unrealengine.com/t/ue4game-folder-on-external-storage/368493/14 "2017-03-15T09:08:02Z")

</div>

Hi Chris, thanks for the solution. But how to compile after modify the AndroidFile.cpp ? Is open the UE4.sln to do compile?

---

<div class="post-metadata">

**Author:** ![wingedrobin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@wingedrobin](https://forums.unrealengine.com/u/wingedrobin)\
**Post date:** [March 15, 2017, 9:38am UTC](https://forums.unrealengine.com/t/ue4game-folder-on-external-storage/368493/15 "2017-03-15T09:38:01Z")

</div>

Of course, that is one of the file in engine sources.

---

<div class="post-metadata">

**Author:** ![BPSailor](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BPSailor](https://forums.unrealengine.com/u/BPSailor)\
**Post date:** [March 16, 2017, 1:51am UTC](https://forums.unrealengine.com/t/ue4game-folder-on-external-storage/368493/16 "2017-03-16T01:51:19Z")

</div>

Thanks a lot, wingedrobin 😃

---

<div class="post-metadata">

**Author:** ![wingedrobin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@wingedrobin](https://forums.unrealengine.com/u/wingedrobin)\
**Post date:** [November 27, 2017, 9:13am UTC](https://forums.unrealengine.com/t/ue4game-folder-on-external-storage/368493/17 "2017-11-27T09:13:19Z")

</div>

Hi, Chris.  
Is this the checkbox that you said?

![221614-not-install-at-ext.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/4/2/342eaa0f67ec7c3fe19478d5a58caba1a7ebbd4a.jpeg)

If yes, is the functionality implemented yet? No matter i check or uncheck the **Use ExternalFilesDir for UE4Game files** , the UE4Game folder is always be created outside of the /data/ folder.

There will create **UE4Game** and **obb** two folder under _/storage/sdcard0_, and create a game project folder under _/storage/sdcard0//data_ but only contain **ca-bundle.pem** and **login-identifier.txt** two files. All files of project are still placed in /storage/sdcard0/UE4Game, not in _/storage/sdcard0//data_.

And the **Install Location** option on the picture seems no use either. So is the only way that I want to place my whole game content into _/storage/sdcard0//data_ folder is to modify the source code of the engine??

PS: I tried in development build and shipping build are the same result.

---

<div class="post-metadata">

**Author:** ![Dertosh](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dertosh](https://forums.unrealengine.com/u/Dertosh)\
**Post date:** [July 16, 2021, 9:05pm UTC](https://forums.unrealengine.com/t/ue4game-folder-on-external-storage/368493/18 "2021-07-16T21:05:16Z")

</div>

wingedrobin give right answer. If you want use internal storage for UE4Game set true **“Use ExternalFilesDir for UE4Game files”** and in shipment will be using internal storage. In another build will be using external storage.

You can see is UE4 sources.  
[https://github.com/EpicGames/UnrealEngine/blob/c3caf7b6bf12ae4c8e09b606f10a09776b4d1f38/Engine/Source/Runtime/Launch/Private//AndroidJNI.cpp](https://github.com/EpicGames/UnrealEngine/blob/c3caf7b6bf12ae4c8e09b606f10a09776b4d1f38/Engine/Source/Runtime/Launch/Private//AndroidJNI.cpp)  
in **JNI\_OnLoad** setting **GFilePathBase**

```
GFilePathBase = FJavaHelper::FStringFromLocalRef(Env, (jstring)Env->CallObjectMethod(*externalStoragePath, getFilePath, nullptr));

```

And **GFilePathBase** use for set on platform **FilePathBase** and **BasePath** when **bUseExternalFilesDir** is true  
in **Java\_com\_epicgames\_ue4\_GameActivity\_nativeSetGlobalActivity**

```
if (bUseExternalFilesDir)
		{
#if UE_BUILD_SHIPPING
			GFilePathBase = GInternalFilePath;
			GOverrideAndroidLogDir = bPublicLogFiles;
#else
			GFilePathBase = GExternalFilePath;
#endif
			FPlatformMisc::LowLevelOutputDebugStringf(TEXT("GFilePathBase Path override to'%s'\n"), *GFilePathBase);
		}

```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_56056ad11](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_56056ad11](https://forums.unrealengine.com/u/anonymous_user_56056ad11)\
**Post date:** [October 6, 2022, 12:16am UTC](https://forums.unrealengine.com/t/ue4game-folder-on-external-storage/368493/19 "2022-10-06T00:16:58Z")

</div>

Reviving this ancient post to inquire about this once again, this time for 12.

Because of the error from the post by @anonymous_user_d263f0c4 in 2016 (Failed to open descriptor file) I have no choice but to completely package my game. (launcher will cause this error regardless of shipping/development build type.)

However, I cannot seem to get save games to work correctly, regardless of what settings I run. I have tried every possible combination of development/shipping/distribution and ExternalFilesDir / Install Location. Nothing will let me even use a save game file on 12. I have also tried a flurry of permissions, both requesting them via blueprint node and adding them to the additional permissions in the project settings.

I’ve seen various “hack” fixes across the forums involving hardcoding the scoped storage directory into save-games and rebuilding the engine, but I can’t get any of those to work either… and they aren’t very scalable.

Any help from Epic or any other dev’s would be awesome.

---

<div class="post-metadata">

**Author:** ![MilkyEngineer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/milkyengineer/32/918676_2.png) [@MilkyEngineer](https://forums.unrealengine.com/u/MilkyEngineer)\
**Post date:** [March 3, 2023, 5:09am UTC](https://forums.unrealengine.com/t/ue4game-folder-on-external-storage/368493/20 "2023-03-03T05:09:53Z")

</div>

Like Dertosh, I came across `bUseExternalFilesDir` in my travels to realise it instead means bUse_Internal_FilesDir in _Distribution Shipping_ builds only.

So if you’re running BuildCookRun, be sure to build for Shipping **and** add the `-distribution` parameter to the end of your build command (or [enable “For Distribution” in the packaging window](https://docs.unrealengine.com/packaging-unreal-engine-projects/#distribution)), as the `MakeApk` code in `UEDeployAndroid.cs` will set `bUseExternalFilesDir` to false if not building in distribution mode.

Additionally, if like me, you decided to put an inline comment after the property in the config file like so:  
`bUseExternalFilesDir=True ; Need this for Save Game`  
Remove the comment, as apparently the `UEDeployAndroid.UseExternalFilesDir` method was still returning false for me due to it.

Note: Leaving this here for any folks coming from search engines. I had to enable this option to get my Save Games working in when `WRITE_EXTERNAL_STORAGE` needs to be disabled (a requirement of Meta/Oculus Quest’s VRC).
