android – I need to know how I use a .text as a database; I just need you to show the data contained in it.


My application is a manual that when the user clicks on the item in the listView the descriptions contained in each item appear, along with a photo. Another thing is how to put the .text data in a ListView. This is my doubt.


Come on!
I'll show you how to load a .txt from the Assets folder:
create a file called dados.txt inside the assets folder It will have the following structure:

item 1;descrição um;image1.png
item 2;descrição dois;image2.png

To load this file use the following code:

 * Carrega um arquivo txt e transforma as linhas em Objeto.
private void load(){
      try {
         final InputStream inputStream = getAssets().open("dados.txt");
         final InputStreamReader inputreader = new InputStreamReader(inputStream); 
            BufferedReader buffreader = new BufferedReader(inputreader); 
            final List<Item> itens = new ArrayList<MainActivity.Item>(0);
            String line = "";
                while ((line = buffreader.readLine()) != null){
                    String[] values = line.split(";");
                    final Item item = new Item(values[0], values[1], values[2]);

    } catch (IOException e) {

 * Representa o objeto que será exibido
public static class Item {
     public Item(final String title, final String description, final String image) {
         this.title = title;
         this.description = description;
         this.image = image;
     public String title;
     public String description;
     public String image;

Hope this helps!

Scroll to Top