free
web stats

Android – Read Text File From Assets Folder in Android Studio

In this post we are going to learn how to make read text file in Android Studio.

Firstly we are going to create new android project like this.

Then we need to a .txt file. I have already created new .txt file named TextFile.txt. Then I’m creating new assets file onder main directory. Then paste this TextFile.txt file.

Now we are going to go activity_main.xml file and add a TextView and a Button.

activity_main.xml file codes here;

Then go to MainActivity.java file. Let’s start to write our codes for read .txt file. Firstly we have to define Button and Text View in here. Then go to Button’s setOnClickListener and write .txr read codes;

MainActivity.java file codes here;

Now we are reading our txt file and write these texts in TextView. Screenshot is here;

Hava a nice day 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *