Check if file exists on SD card on Android

后端 未结 6 672
悲哀的现实
悲哀的现实 2020-12-05 20:57

I want to check if a text file exists on the SD card. The file name is mytextfile.txt. Below is the code:

FileOutputStream fos = openFileOutput(\"sdcard/myte         


        
6条回答
  •  一生所求
    2020-12-05 21:11

    The FileOutputStream constructor will throw a FileNotFound exception if the specified file doesn't exist. See the Oracle documentation for more information.

    Also, make sure you have permission to access the SD card.

提交回复
热议问题