Android: viewing files from Windows explorer - android

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:
Show hidden files and folders in Windows Explorer
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)
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!

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.

Related

Folder added in Android external storage, but was not showed correctly on computer via USB connection

I've created a folder in my program and use MediaScannerConnection to get it visible on Computer.
I did just the same as the answer to this question: add a folder in android program
Now the problem is that, on the computer, the folder doesn't show as a folder, but as a blank file.
Does anyone knows why this happens and how to get the folder show in correct way?
Thanks.

database file does not appear under data/data/packagename/databases or anywhere else

First I have been searching for a solution for acouple of days now. It is very strange as the answer to my problem maybe very simple.
I am trying to make the simplest code to create sqlite database. there is plenty of examples in the web. the code does not generate any error and the application appears on the device. but when I try to locate the database in the specified location as in the title it does not seem to be created.
my specific questions
1-does the device has to be rooted to create a database file.
2-do I need special manualy entered permissions in the manifest file to create the database file.
3-Is there any prior settings that I have to do in android studio or a plug-in that I have to add.
4-Do I have to create the sub folders manualy because some devices dont even have the second data subdirectory of the main data directory in the main internal storage. Any way I created the folders and subfolders but no database appeared after running the application. I use a file explorer in the target device to inspect the existance of the database file.
many thanks for any attempts to help me as I seem to be stuck for few days now.
I found the files in the internal device memory using a root explorer.
The strange thing I have not seen any tutorial which alerts me to the hidden memory and root explorer. time wasted but along the way I learned many new things.
thanks all

Where is the SQLite datase file?

I've created an app using Android Studio and it has a database file handler. I've gone through a few post and everywhere they are saying go to data\data\ folder to get the app folder. But mine doesn't show any folder for my app. Do I have to manually set this file location to be created? How can I find my database.db file?
It should be automatically placed in data/data/databases in your app folder unless you specify otherwise. Are you sure it is created?
That is /data/data/package-name/databases/dbfilename
I have another suggestion. If you have enabled backup for your application, you might be able to use ADB BACKUP, like suggested here: http://blog.shvetsov.com/2012/09/backup-your-android-without-root-or.html
The database files are located in the following folders.
/data/data/packagename/databases/
You can access the .db file only on emulator, its not possible on actual device. In the android studio open the DDMS perspective, there on the left hand side you will find the storage structure, there in data/data/ you will get the file you are looking for

Accessing data from device in Android Studio

it's my first question here. I searched a lot on the site but didn't find any answer for my question.
Basically, I want to load a directory containing jpeg and mp3 in the tablet and retrieve the path from these files and put them in a SQLite database. I have no trouble using the database but I don't know how to retrieve the paths of the files or even to verify the existence of the directory. Any hint on how to access these files without putting them in the application drawable and sound folder would be appreciated. Thanks!
Goto the Android Device Monitor in the android studio and new poup window will open with the devices list in the left pane and in the right pan select the File Explorer Tab and that's it

Programatically deleted files still show up in Windows Explorer

My app polls a directory on the SDcard for the appearance of new files that where dropped there by the user from Windows file explorer over the USB connection. When a new file appears, my app processes it, and then deletes it, however the file still shows up in Windows file explorer. I know the file is gone because it no longer appears in the DDMS file explorer, and my poller doesn't get triggered again. Any insights into how Android interacts with Windows file explorer would be appreciated. I've tried playing around with MediaScannerConnectionClient, which helps with getting programatically created directories to appear, but does nothing to get files to disappear.
I'm running Android 3.2 on an Acer Iconia A500. My PC is running Windows XP. The files are .csv and .txt files. I'm using File.delete() to delete them.
Thanks.
This is an old issue, but the above answers were not really helpful to me, so I tried some other stuff and the following worked for me.
Just call the scanFile method of the MediaScannerConnection on the file to be deleted after you delete it:
File file = new File("...");
String absolutePathToFile = file.getAbsolutePath();
file.delete();
MediaScannerConnection.scanFile(context, new String[]{absolutePathToFile}, null, null);
I am guessing that the scanner scans the file location, does not find the file and updates the OS's file index or whatever takes care of making the files visible to the explorer.
Android, being a Linux-based OS, will delete a file only when the last file handle to it is closed. The file name may disappear earlier, though.
On Windows, having an open file handle means the file name still exists. So Windows simply doesn't expect the file to disappear like it does.
If the files are gone when you refresh, it may just be because Windows doesn't expect the directory to change out from underneath it, and so doesn't check for changes.

Categories

Resources