Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Android Kotlin assert list is empty but file is in folder

I am trying to read a file in via Android assets folder. For this I made a assets folder like here. I made a file and it is shows in the explore:

enter image description here

When I run in the onCreate method:
Log.d("Test", assets.list("/").contentToString()) The output is [].

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Also when I run:

assets.open("Injector.js").bufferedReader().use {
    Log.d("Test", it.readText())
}

The output is "" or Nothing.

Is there anybody familiar with this issue or has any ideas how to resolve this?
If you need more information please let me know.

Thanks in advance

>Solution :

try with applicationContext like this:

applicationContext.assets.open("Injector.js").bufferedReader().use {
     Log.d("Test", it.readText())
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading