Answer the question
In order to leave comments, you need to log in
How to populate a ListView from a text file?
Hello. I have such a question, is it possible to fill ListView in androyd somehow from a text file?
In java, I can easily find and read a text file, but in android something doesn’t work.
Here interests from the file input.txt it is possible to add the text in ArrayAdapter?
Answer the question
In order to leave comments, you need to log in
You can, transfer input to the asset folder of the project. Through the Activity, get the AssetManager and read the contents of the file through it with the usual InputStream.
in the res folder resources, to work like with a file, put it in an asset, although if there is not much data, you can use an array of strings
<string-array name="items">
<item>0 item</item>
<item>1 item</item>
<item>2 item</item>
....
</string-array>
String array[] = getResources().getStringArray(R.array.items);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question