Accessing text files and string related stuff for Android platform


I want to write a simple flash card application as my first Android app. So i went around and look for some documents. However I am a tad confused (naturally) about how to do text stuff because the Haxe way might be target sensitive so in that regard which way of accessing text files, dealing with string objects etc is the right way if I am going to be targeting Android? The rest of th gui etc sounds fine since I will be using OpenFl related stuff, I assume.

Btw when it says like “class Available on cpp, macro, neko, php” in Haxe documentation, does that mean that it can be used for Android(because of cpp) ?


1 Like

Is the text file included with your app in the assets folder? If so it can be read using Assets.getText(id) in a similar way to how you’d load an image.

1 Like

Yeah i guess it will be like a local simple database file or I will load it from a url.

So I use OpenFl assets to load the text file, then jump to Haxe’s standard text modification modules to manipulate them?

Yeah that sounds about right. Once you use the Assets.getText(id) you will have the string that is the contents of your file. You can do whatever you want with that using haxe.

To load from a URL you’d need to use a URLLoader but once you’ve fetched it the same applies again, it’s just a String.



nevermind i was not supposed to use “new” there.

It says that “Unexpected getText” when I run lime test linux


import openfl.display.Sprite;
import openfl.Assets;

class Main extends Sprite {

    public function new () {

        super ();
        var textFile= new Assets.getText("assets/texttfile.txt");