Environment.getExternalStorageDirectory().getAbsolutePath() gives a different path - Android

前端 未结 2 873
故里飘歌
故里飘歌 2020-12-16 01:39

I try to write something into my phone memory.

At first, I hard-coded the path as:

myFile = new File(\"/sdcard/\" + txtName.getText() + \".txt\");
         


        
2条回答
  •  忘掉有多难
    2020-12-16 02:25

    Remove the .getAbsolutePath() and it will be fine. Environment.getExternalStoreDirectory() will give you the path to wherever the manufacture has set their external storage.

提交回复
热议问题