# Access File created in UE4 using ioStream in Android

**URL:** <https://forums.unrealengine.com/t/access-file-created-in-ue4-using-iostream-in-android/480269>\
**Category:** Mobile\
**Tags:** unreal-engine, Android, CPP, question\
**Created:** [March 14, 2021, 9:14am UTC](https://forums.unrealengine.com/t/access-file-created-in-ue4-using-iostream-in-android/480269 "2021-03-14T09:14:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![iam\_Raavanan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@iam\_Raavanan](https://forums.unrealengine.com/u/iam_Raavanan)\
**Post date:** [March 14, 2021, 9:14am UTC](https://forums.unrealengine.com/t/access-file-created-in-ue4-using-iostream-in-android/480269/1 "2021-03-14T09:14:30Z")

</div>

Hi All,

```
   I was trying to integrate an FIT SDK into game I was working on. I got SDK of FIT as C++ and I wanted to create a file using fstream in Unreal. But, it was failed.

```

So, I created a file in Unreal using

```
FFileHelper::SaveStringToFile(TEXT(""), *path);

```

Then, I tried to access the file using ios::fstream

```
std::fstream InFile;
InFile.open(TCHAR_TO_UTF8(*path), std::fstream::out);

```

But, I can’t able to access it. As file has been created successfully in the UE4.  
But, when I tried to access the file from the file location after packaging. (Android ) it was not working as expected.

```
if (InFile.fail())
{
     UE_LOG(LogTemp, Warning, TEXT("FAILED"));
}
else
{
     UE_LOG(LogTemp, Warning, TEXT("SUCCESS"));
}

```

Everytime, it was going into the IF condition. Which means, fstream can’t able to access the file or what is the problem here.

Can anyone help me to understand here and also guide me through right direction.

Update:  
In Editor, it was working fine. When I make build and run it on the device (Android) that’s when I was not able to access the file.

Thanks

---

<div class="post-metadata">

**Author:** ![YedesCodes](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/yedescodes/32/981996_2.png) [@YedesCodes](https://forums.unrealengine.com/u/YedesCodes)\
**Post date:** [March 16, 2021, 9:01am UTC](https://forums.unrealengine.com/t/access-file-created-in-ue4-using-iostream-in-android/480269/2 "2021-03-16T09:01:58Z")

</div>

Hi,

Can you please post your path ? because I think that the problem is there.  
Also the method **FFileHelper::SaveStringToFile** returns a **bool** , you can check whether you function returns true or false for the file creation.

So I tested your code by changing the path, using the Unreal Engine class **FPaths** to get the project directory and create the file using the same method as you and i get a success for the IF condition.

This is the code I used :

```
   FString path = FPaths::ProjectDir();
	path += "Content/TextFile.txt";

	
	bool bTest = FFileHelper::SaveStringToFile(TEXT("my awesome file"), *path);
	UE_LOG(LogTemp, Error, TEXT(" bTest : %d"), bTest);

	std::fstream InFile;
	InFile.open(TCHAR_TO_UTF8(*path), std::fstream::out);

	if (InFile.fail())
	{
		UE_LOG(LogTemp, Warning, TEXT("FAILED"));
	}
	else
	{
		UE_LOG(LogTemp, Warning, TEXT("SUCCESS"));
	}

```

So my file will be created in the **Content** folder of the project and I see that my text file is successfully created with the test in it.

Also the code above is in my Actor **BeginPlay()**.

Can you post more about your code to better understand what’s going wrong ?

Hope this helps 🙂

---

<div class="post-metadata">

**Author:** ![iam\_Raavanan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@iam\_Raavanan](https://forums.unrealengine.com/u/iam_Raavanan)\
**Post date:** [March 16, 2021, 9:53am UTC](https://forums.unrealengine.com/t/access-file-created-in-ue4-using-iostream-in-android/480269/3 "2021-03-16T09:53:48Z")

</div>

Thanks Hakaishin0895,

Sorry, I forgot to mention, I was facing this issue only on device(Android). I was trying to access the file. It was created in Android packaged build. But, when I try to access via fstream It was failing.
