0

I am using the below code for reading my file and it is working fine, but now I want to add new text to that file. Please help me

private void loadingDictionary() {
// TODO Auto-generated method stub
    AssetManager mgr;

    try{
        mgr = getAssets();
        InputStream is = mgr.open("dictinary.txt");
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader br = new BufferedReader(isr);
        StringBuilder  stringBuilder = new StringBuilder();
        String ls = ",";
        while(( line = br.readLine() ) != null){
        stringBuilder.append( line );
        stringBuilder.append( ls );
    }
    dictinaryLines = stringBuilder.toString();
    dictLinesArray = dictinaryLines.split(ls);
    }
    catch(IOException e1){
    }

}

I want to append the new text to the already existing data. Please help me.

Happy
  • 169
  • 1
  • 4
  • 10
  • You cannot write the file into assert/raw fold: look this: http://stackoverflow.com/questions/3760626/how-to-write-files-to-assets-folder-or-raw-folder-in-android – buptcoder Apr 22 '13 at 06:06

2 Answers2

0

As far as I know you can not write to the assets folder. You should copy the data from your assets folder to the private of your application or even to the external storage, depending on how confident your data is.

See How to write files to assets folder or raw folder in android?

Community
  • 1
  • 1
fish
  • 828
  • 1
  • 6
  • 14
0

You can't. How ever you can append a string called by res/values/strings.xml. If you were doing a theme I would have suggested to declare a string in res/values.strings.xml, and append it, then have whatever app you wanted to change whatever text to read from strngs.xml.