开发者

Write/delete content file text as raw resource android

I make android application that read textfile.txt from resource/raw. And it's work fine. Here is the code:

    BufferedReader bufferreader = new BufferedReader(new
            InputStreamReader(getResources().openRawResource(R.raw.textfile)));
    String bufferLine;
    String tempText = "";
    try{
        w开发者_JAVA技巧hile ((bufferLine = bufferreader.readLine()) != null){
            tempText = tempText + bufferLine;
             }
            } catch (IOException e){
            }

Now, I need also to access this raw resource textfile by modify(write) or delete the content. Is there anyway to do it on android ?


Use the external storage to store the file after you have modified it.

How you use the external storage depends a bit on what version you are targeting, but it's explained in the documentation that I linked to.

Files that you place in the external storage associated with your application will be deleted if your application is uninstalled and your target version is API level 8 or above.


You can't write resources. Copy the file in the application internal memory or in the external storage (sd card or else) and then you can modify it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜