Witam, próbuję napisać aplikację na androida, która ma pobierać z pliku txt dane, i wpisywać je do arraylist oraz do groupitem w expendables list viewer. Próbowałem na parę sposobów, ale coś mi nie idzie.

Próba 1:

	public class FileReader extends Activity{
	
		String sciezka = "file:///zespoly.txt";
		
		FileInputStream fis;
		fis = openFileInput(sciezka);
		StringBuffer fileContent = new StringBuffer("");

		byte[] buffer = new byte[1024];

		while (fis.read(buffer) != -1) {
		    fileContent.append(new String(buffer));
		}

Próba 2:

ArrayList<String> lista = new ArrayList<String>(); 
		String sciezka = "file:///zespoly.txt";
		
		 AssetManager assetManager = getAssets();
        // To get names of all files inside the "Files" folder
        try {
            String[] files = assetManager.list("Files");
             
            for(int i=0; i<files.length; i++)
            {
                txtFileName.append("\n File :"+i+" Name => "+files[i]);
            }
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
         
        // To load text file
        InputStream input;
        try {
            input = assetManager.open("helloworld.txt");
             
             int size = input.available();
             byte[] buffer = new byte[size];
             input.read(buffer);
             input.close();
 
             // byte buffer into a string
             String text = new String(buffer);
             
             txtContent.setText(text);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }