Activity提供了getCacheDir()和getFilesDir()方法:

getCacheDir()方法用于获取/data/data//cache目录

getFilesDir()方法用于获取/data/data//files目录

//==================================================

将文件写入SD卡内:

获取SDCard的状态:

Environment.getExtemalStorageState()

Environment.MEDIA_MOUNTED手机装有SDCard,并且可以进行读写

获取SDCard的目录:Environment.getExtemalStorageDirectory()

//=============================================

File saveFile=new File("/sdcard/zhzhg.txt");

或:File sdCardDir=new File("/sdcard");//获取SD卡目录

File saveFile = new File(sdCardDir,"zhzhg.txt");

FileOutputStream outStream = new FileOutputStream(saveFile);

outStream.write("文件的读写".getBytes());

outStream.close();

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-07
  • 2021-06-11
  • 2021-12-07
  • 2022-01-11
  • 2022-02-04
  • 2021-12-27
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案