File reading not working for android
<p>I am an android newbie and wrote this code for file handling but for some reason i am always getting back null values from the file. I also tried using readline() but got the same result. Would appreciate any help.</p>

<pre><code>        @Override
        public void onClick(View v) 
        {
            // TODO Auto-generated method stub
            String file = "test123";
            try 
            {
                OutputStream out =  v.getContext().openFileOutput(file, MODE_PRIVATE);
                InputStream in =  v.getContext().openFileInput(file);
                WriteFile(out);
                String str = ReadFile(in);

                Toast.makeText(v.getContext(), str, Toast.LENGTH_LONG);
            } catch (FileNotFoundException e) 
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    });
}

public static void WriteFile(OutputStream out)
{
    OutputStreamWriter tmp = new OutputStreamWriter(out);

    try 
    {
        for (int i = 0 ; i &lt; 10; i++)
        {
            tmp.write(i);
        }
    } 
    catch (IOException e) 
    {
        // TODO Auto-generated catch block
        e.printStackTrace();            
    }
}

public static String ReadFile(InputStream in)
{
    InputStreamReader tmp = null;
    String str = "";        

    tmp = new InputStreamReader(in);
    BufferedReader reader=new BufferedReader(tmp);                      

    try 
    {
        for (int i = 0; i &lt; 10; i++)
        {
            str += " " + reader.readLine();             
        }           

    } 
    catch (IOException e) 
    {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }   

    return str;
}    
</code></pre>

<p>}</p>
