How to save parsed text file in internal/external storage in android

后端 未结 3 1347
余生分开走
余生分开走 2021-01-13 16:51

Currently I am working in project where I need to parse a remote text file and store it in local storage (internal/external). I am able to parse the text file but unable to

3条回答
  •  孤城傲影
    2021-01-13 17:33

    Replace this lines

    File myFile = new File("sdcard/mysdfile.txt");
    if(!myFile.exists()){
      myFile.mkdirs();
     }
    myFile = new File("sdcard/mysdfile.txt");
    

    with

    //Saving the parsed data.........

    File myFile = new File(Environment.getExternalStorageDirectory()+"/mysdfile.txt");
    myFile.createNewFile();
    

提交回复
热议问题