3

I have just made an application that uses a SQLite database, and I finally managed to export the database file onto the computer without having to root the Android device. The method I am using is mostly from code I found on various Stack Overflow question/answers. I am basically saving the database file to the public Download folder.

When I look on the Android device using a file explorer, I can see the correct SQLite file in the correct folder (Download folder). However, when I open up the same folder in Windows Explorer from my PC, I can not see the file in the exact same folder.

Now here is the strangest part: When I copy or move the file (using the Android device), even if I am copying and/or moving the file TO THE EXACT SAME SPOT, as soon as I have finished doing this the file instantly becomes visible in Windows Explorer.

I do not want the user to have to do this manually every time, so does anyone know of any way to make sure that the file will be visible right away? Thank you in advance!

Things I have tried so far:

  1. Show hidden files and folders in Windows Explorer

  2. Programmatically moving the file to a new folder within the application itself (the move to the new folder works, but the file still remains invisible in Windows Explorer until manually moving/copying the file again)

  3. Searched StackOverflow for similar issues and have been unsuccessful.

And if anyone wants to see some of my code, let me know and I will post it, but I am thinking that this is less to do with my code and more to do with Android/Windows interaction. And this is where I got my move folder function from: stackoverflow.com/questions/4178168/how-to-programmatically-move-copy-and-delete-files-and-directories-on-sd

Thank you!

Community
  • 1
  • 1
  • I think that's because Media Scanner. Try apps like Rescan Media. – Onur Jun 10 '14 at 19:23
  • @Onur You were right about Media Scanner being the issue. I will post a solution in a second. Thank you for setting me on the right track :) – user3727351 Jun 10 '14 at 19:31
  • Never mind I can't post answers because I am too new of a user. Here is what I was going to write: – user3727351 Jun 10 '14 at 19:35
  • 1
    I actually found the solution on another Stack Overflow question which I had already seen but hadn't realized was relevant. Onur's comment let me know it was relevant though. I just needed to add this line of code: MediaScannerConnection.scanFile(this, new String[]{"your path here"}, null, null); and it all worked properly (at least for initially becoming visible). I am not sure if it will update in real time with me saving the file from the Android device, but that is not really what my question was about. – user3727351 Jun 10 '14 at 19:36
  • 2
    And last comment, here is the link: http://stackoverflow.com/questions/7429087/cant-see-a-file-in-windows-written-by-an-android-app-on-sd-card-unless-i-force – user3727351 Jun 10 '14 at 19:38

1 Answers1

0

I had a similar issue and it was not visible in Windows because I hadn't given it a file extension.

Give it a file extension if you haven't already.

JamesK
  • 164
  • 8
  • Thanks for your interest man, I appreciate it! I actually had just found the answer (see my comment above) right before I saw your post. – user3727351 Jun 10 '14 at 19:37