Saving file to phone instead of SD card

前端 未结 4 1956
孤街浪徒
孤街浪徒 2021-01-20 14:45

In my app I save an XML file to the user\'s SD card by doing File newxmlfile = new File(Environment.getExternalStorageDirectory() + \"/Message.xml\");

B

4条回答
  •  一个人的身影
    2021-01-20 15:44

    Got it by changing

    Environment.getExternalStorageDirectory() + "/Message.xml"
    

    into

    Environment.getDataDirectory() + "/data/com.companyname.appname/files/Message.xml"
    

提交回复
热议问题