开发者

Application writes file to internal sd card, but Windows doesn't see the file

So, what I'm trying to do is write data to a file on the sdcard and then have windows read the file.

The issue I'm seeing is that windows never sees my new files until I reboot the xoom. The xoom has OS versin 3.2 and I am building to the SDK version as well. Once the xoom is rebooted and I navigate the xoom within windows my new directory and files show up after refreshing the directory a couple of times. This is an issue with an application that I am writing as I am exchanging information between the xoom and a device.

My code for writing out the file on the xoom is pretty straight forward, but I must be missing something if I need to reboot the xoom before windows can see the file I just created. I feel that shouldn't be needed.

  String path = Environment.getExternalStorageDirectory().getPath() + "/TEST3/";
  File dirPath = new File(path);
  dirPath.mkdirs();

  try
  {
     FileOutputStream fw = new FileOutputStream(path + "test4", false);
     fw.write(mac.getBytes());
     fw.flush();
     fw.close();
  }
  catch (IOException e)
  {
     // TODO Auto-generated catch block
     e.printStackTrace();
  }

Just for some more background on why I'm doing this which may help understand what i'm trying to do.

Basically I need to connect a Xoom to a device where they will exchange information with each other over USB. The device will be mounting the xoom with mtpfs which is already implemented. When connected and mounted via USB the Xoom and device will write out a file with specific content. Each one is writing to separate files named appropriately. Then when finished they will read each others file, based on a second file written by each side to signal they are done writing.

So as you can see having开发者_运维百科 to reboot in the middle of this just to see files would be pretty awful. This application is all a custom job and will not be in the market or anything like that. The xoom itself will only have this application running along with some other custom applications.

Thanks for any help that you can give me.


Use MediaScannerConnection and scanFile().

On Honeycomb and higher, Android has switched to MTP and away from USB Mass Storage mode. On the whole, this is a good thing, but it means only indexed files show up.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜