Populate a String array with text file stored on sdcard
<p>I have a text file on my sdcard filled like this :</p>

<p>test1</p>

<p>test2</p>

<p>test3</p>

<p>I would like to populate a String array by reading the file and get an array like this :</p>

<p><code>String[] val = {"test0","test1","test2"};</code> </p>

<p>This is how I read the file but how can I read each line and fill the array ? :</p>

<pre><code> public void ReadSettings(){

    try{             
           File f = new File(Environment.getExternalStorageDirectory()+"/file.txt");             
           FileInputStream fileIS = new FileInputStream(f);          
           BufferedReader buf = new BufferedReader(new InputStreamReader(fileIS));           
           String readString = new String();                

           while ((readString = buf.readLine()) != null) {

               Log.d("line: ", readString);   

           for (int i=0 ; i &lt; 3 ; i++){
                      val[i] = readString;

            }

        } catch (FileNotFoundException e) {          
           e.printStackTrace();          
        } catch (IOException e){             
           e.printStackTrace();          
    }    
} 
</code></pre>

<p>This is what I get unfortunetly :</p>

<p><code>String[] val = {"test2","test2","test2"};</code> </p>

<p>Any help would be appreciated. Thanks !</p>
