Text File Show Problem In Android Apk
Hello,
My name is Mehmet. I’m 49. I’am a civil engineer and computer programmer. Now, I am making a the Holy Quran reading application by reading from .txt text files by Unity. I will talk about the problem I encountered while I coding.
How do I usually code?
Normally, I used to add text components to each book page and copy-paste each page from the text editor. However, I think this method takes a lot of time and is useless. When I researched I can read and list my pages/books from single file written through the .txt file in Unity.
What I do?
I created the Assets / StreamingAssets / Kuran folder in my application. I placed my file named SabanPirisTrCeviri.txt.
I used sample script as follows. I use this script in many places in the application that I write. I installed all versions of Unity 2019, 2020 and 2021 separately.
My C# Script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.IO;
using System.Linq;
public class GetTextSureSure: MonoBehavior
{
public Transform contentWindowSure;
public GameObject recallTextObject;
public int sureNo;
private void Start ()
{
string readFromFilePath = Application.streamingAssetsPath + "/Kuran/SabanPirisTrCeviri.txt";
List <string> fileLines = File.ReadAllLines (readFromFilePath) .ToList ();
foreach (string line in fileLines)
{
if (line.StartsWith ((sureNo.ToString () + "|")))
{
recallTextObject.GetComponent <Text> () .text = line;
Instantiate (recallTextObject, contentWindowSure);
}
}
}
The Problem
My application runs smoothly on Unity Game screen, Device Simulator. I can also get builds for Android. Apk file is created without any problems. The apk file is installed on the Nox Player or mobile phone without any problems. The application works fine, but none of the texts written in the .txt file do not appear on the phone screen or in the Nox Simulator Program. If the script codes were not correct, they would not work properly in UnityGame. The device is also working correctly in the Simulator. Although it works correctly in Device Simulator but it does not work correctly on devices/programs running apk.
Attachments
1 Unity Package file is attached. (for you to open and review).
Thank you in advance for your help.
Kind Regards.
Your answer

Follow this Question
Related Questions
Problem with text size 0 Answers
Why isn't my C# code sending updates to my text scoreboard? 1 Answer
Objects countdown to exit game. 0 Answers
Stuttering in build 0 Answers
Score wont display 0 Answers