How to write and read data into the file base on different language
<p>Actually in my app i have an <code>EditText</code> box and an <code>TextView</code>. In this <code>EditText</code> box whatever i write is stored in the file. So when i open my app again the stored text is shown in the <code>TextView</code>. All works fine for me. But whenever i change the language in Russian, the Keyboard that appear on click of <code>EditText</code> box contain Russian character. Now when i follow the same process of storing and reading the text that i entered, the while reading it read some garbage value and display in <code>TextView</code> instead of the text that i have stored. So my questions is why this happen only when i stored the text in other Language, because in storing the text in english language it works fine. The code that i have used while storing data into the file is shown below.</p>

<p><strong>Write Notes into the file and register</strong></p>

<pre><code>public void writeNotesToFile(Context c)
{
    SharedPreferences preferencesWrite  = c.getSharedPreferences("myPreferences", 0);
    SharedPreferences.Editor editor  = preferencesWrite.edit(); 

    // write notes count into the  register
    editor.putInt("notesCount", m_noteCount);
    editor.commit();

    // write notes  to the  file
    SimpleDateFormat sdFormater = new SimpleDateFormat("dd-MMM-yyyy", Locale.US);
    File file = c.getFileStreamPath("Notes");

    if (m_noteCount &gt; 0)
    {
        if(!file.exists())
        {
            try 
            {
                file.createNewFile();
            } 
            catch (Exception e) 
            {
                Log.i("ReadNWrite, fileCreate()", "Exception e = " + e);
            }
        }       
        try 
        {
            FileOutputStream  writer = c.openFileOutput("Notes", Context.MODE_PRIVATE);
            for (int i = 0; i &lt; m_noteCount; i++)
            {
                String noteDate = sdFormater.format(m_arrNoteDate[i]);
                writer.write(noteDate.getBytes());
                writer.write(" ".getBytes());
                writer.write(m_arrNoteString[i].getBytes());
                writer.write("~`".getBytes());

            }
            writer.close();
        } 
        catch (Exception e) 
        {
            Log.i("ReadNWrite, fileCreate()", "Exception e = " + e);
        }
    }
    else
    {
        try 
        {
            file.createNewFile();
        } 
        catch (Exception e) 
        {
            Log.i("ReadNWrite, fileCreate()", "Exception e = " + e);
        }
    }

}
</code></pre>

<p><strong>Read notes from the file and register</strong></p>

<pre><code>public void readNotesFromFile(Context c)
{       
    SharedPreferences preferencesRead = c.getSharedPreferences("myPreferences", 0);

    // Reads notes count from the  register
    m_noteCount = preferencesRead.getInt("notesCount", 0);

    // Reads notes from file
    String note = "";
    char nextCharacter;
    int count = 0, ch;
    SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy", Locale.US);

    File file = c.getFileStreamPath("Notes");
    if (m_noteCount &gt; 0)
    {
        if(file.exists())
        {
            try 
            {
                FileInputStream fin = c.openFileInput("Notes");
                while( (ch = fin.read()) != -1)
                {
                    nextCharacter = (char)ch;
                    if (nextCharacter == '~')
                    {
                        ch = fin.read();
                        nextCharacter = (char)ch;
                        if (nextCharacter == '`')
                        {
                            int i=note.indexOf(" ");
                            String temp = note.substring(0, i);
                            try
                            {
                                m_arrNoteDate[count] = formatter.parse(temp);
                            }
                            catch (Exception e)
                            {
                                // To handle dates saved before the file was written in Local.US format.
                                // This code can be removed after few releases and all user have migrated.                          
                                SimpleDateFormat defFormatter = new SimpleDateFormat("dd-MMM-yyyy");
                                m_arrNoteDate[count] = defFormatter.parse(temp);
                            }
                            m_arrNoteString[count] = note.substring(i + 1);
                            count++;
                            note = "";
                        }
                    }
                    else
                    {
                        note = note + nextCharacter;
                    }
                }
            } 
            catch (Exception e) 
            {
                Log.i("ReadNWrite, readFile()", "Exception e = " + e);

            }
        }
    }
}
</code></pre>
