tyczj
tyczj

Reputation: 73753

Created folder shows on device but not on PC

I am trying to create a folder that users can put stuff in and use in the app so I do this

File exportDir = new File(Environment.getExternalStorageDirectory()+"/BCAData");
           if (!exportDir.exists()) {
              exportDir.mkdirs();
           }
           File file = new File(exportDir, dbFile.getName());

           file.createNewFile();

If I use a file explorer program like Astro File Manager I see the folder fine but when I plug the device into my PC the folder is not there to put stuff in.

is there something else that I have to do for it to be used on a PC?

Upvotes: 0

Views: 358

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006724

At minimum, you need to get MediaStore to update its index, such as via scanFile() on MediaScannerConnection, as I outline in this blog post.

Depending on your PC's operating system (and possibly depending on the device), you may still not see changes while the device is plugged in. It appears that the PC does not necessarily "see" changes, even with the index updated, until you unplug and plug the device back in.

Upvotes: 1

Related Questions