I'm using HTC Dream and trying to read the images stored in the "default" album folder of this phone. But I've yet to found out what's the folder path to those images file.
When I mount the phone to my comp, some of the default images are in:
/E0FD-1813/DCIM/
and the photos taken using the phone are stored in
/E0FD-1813/DCIM/100MEDIA/
But using those paths, accessing the images throws a "No Such File" error.
So
do you know what's the path to that image folder? What would be the path patterns (if any) in other Android phones?
I don't need to set any additional permission to access those files, do I?
Do you know how I can build a "file browsing" widget in my activity? I've searched and seems like there is no such widget and I've to install app that does file browsing. In any case, how to incorporate that as a file-browsing view in my current activity?
Thanks for your kind advice!
But I've yet to found out what's the folder path to those images file.
There is no single folder.
do you know what's the path to that image folder?
There is no single folder. Use the MediaStore content provider.
Related
I am trying to make an app app that will be used to upload a file to the Firebase Storage. I don't want the user to have to choose a file instead i want to package the file with the app. (e.g in the raw/asssets folder).
I have tried several things and I can't make sense of anything. I have no direction. I watched a few tutorials on youtube but all of them use 'choose a file' method.
Any help is greatly appreciated.
You cannot get the absolute the path of the file located in assets. Because those files which are located inside the assets folder does not have the absolute path because they are packaged with the application. But you can use an AssetManager object to get an InputStream on an asset.
So, I am trying to place an image in a layout programmatically and I can do this, but only using the mipmap resources. I want to place the full image onto the layout. The answers I have come across mention bitmaps and file paths. What I am confused about is the file path part. Does this mean a file path on the computers source files, or does it mean a file path on the android device in which case, how can I find the image when it is part of the apps resources, not in gallery or to be taken from the camera. If i create a new directory in the project, I can't use R.XXX to find it as it is not there. Under Android the directory does not show up either and dragging an image to the directories under Android does nothing either.
You should put images in res/drawable folder
I'm working on an Android application that needs to store media (document files like pdf or so for later reading) but the main requirement is that all media files have to be accesible through an absolute path (a physical path on filesystem).
I'd like to avoid copying files to external storage (like sdcard or phone internal memory) so to prevent that if application is uninstalled those files remain in phone (and of course to avoid duplicating the size in kb for each file) and instead to keep files in iny App internal resources folder, but tried "file:///asset_folder" whith no success. As far as I know "file:///asset_folder" only Works for a webview to Access www folder but not for regular files.
I'm not sure if there is any app internal data folder which I can access through an absolute path or if not which is the best way to store App resource files.
Thanks in advance!!
Edit: To make it more clear, the resource files are already bundled with the App, and not written during runtime, and what I'd like to know is where to put them so I can later Access them via absolute path for Reading.
To retrive your app specific data
openFileInput(file_name)
To save your app specific data
openFileOutput(file_name, Activity.MODE_PRIVATE)
Update : Read from asset folder. (InputStream)
getAssets().open(fileName);
getAssets().open(fileName, accessMode);
check the image to where to put asset files
now to make other app readable your files from private data/data directory use content providers.
You can not write data inside asset_folder because it is packed on apk file. You can use sd card or location where your app is installed inside internal memory.
I keep some png files on the user's sd card. Some users report that these images are showing up in their gallery application. Sounds like the gallery implementation on some devices search out any image files they can find on the sd card and show it in the gallery. Is there a way to tell the system not to include these images in the gallery? It's just an annoyance to the users.
Thanks
You can hide individual files from the gallery with a . prefix. For example .myimage.png
I'm not sure what version dependencies the above has and it doesn`t work with some third-party picture tools like the Gallery.
You should add a file named .nomedia into the directory where your images are. You may need to eject and re-insert the SD card before the images disappear from gallery (or otherwise trigger the media scanner) after creating this file on a phone that the Gallery has already picked up the files in the Gallery.
I think the .nomedia option is the best solution, although again, third party tools may not respect the .nomedia flag.
Hiding your files from the Media
Scanner Include an empty file named
.nomedia in your external files
directory (note the dot prefix in the
filename). This will prevent Android's
media scanner from reading your media
files and including them in apps like
Gallery or Music.
In http://developer.android.com/guide/topics/data/data-storage.html#filesExternal
You may also consider saving those files as cache files or in the internal memory. More info in that link.
just keep the files in a folder and name the folder starting with a '.'
for example:
Pictures
Videos
.private--> will not be scanned for any media
Eboks
Along with these solutions using picasa is an alternative too... and .nomedia or .foldername suggestions are generally useful but...
Including accepted answer none of the solutions solve album covers problem.
A large number of android users are storing album covers inside the album folder and .dirname or .nomedia solutions are hiding all from both gallery and music player. The required functionality is hiding from gallery and showing in music player (else there is no reason for not deleting cover pics if we will not see them right? )
Here is the solution ;
Rename all album cover picture files to albumart.jpg
(or what picture you desire to hide from gallery)
This way gallery will not include them and music player will still use :)
Alternatively for any folder if you place a folder.jpg file in it that file will be ignored by gallery application.
As you can see we can only exclude max 2 files (pictures) from gallery application, not more :(
After you do this changes no need to clean caches of gallery and media scanner and reboot (still an option) just run an application that triggers scanning of media on every run. I prefer vaulty it refreshes media gallery on every run on photos, but there are lots of apps, maybe you already have one installed , just use it no need to install an application for just this media scan deal.
Knowledge source : http://code.google.com/p/android/issues/detail?id=35879
While making external directory use something like this
File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory("YourDirectoryName"),"YourFolderName");
Instead of
File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "YourFolderName");
These files won't be detected by gallery for more reference check saving media files on this link
http://developer.android.com/guide/topics/media/camera.html#intent-receive
Neither Windows nor Android allow the creation of the file .nomedia
It's seen as a file extension without a name.
i tried everything but only this solution worked 100% you need to plug in your urb and format the sdcard check quick format box and press on restore defaults and then it will show everything in ur gallery just you need to move all your images again :)
You can easily create the folder in Windows using Powershell
New-Item -path 'C:\Users\Google Drive\Pictures\.nomedia' -itemtype directory
I am creating android application which contains DB that needs to be hidden(not able to access by the user)in the SD Card. Can anyone tell me how to do this?
Any file stored on the SD card is accessible both by applications running on the phone, and by users who have mounted the SD card (both while it's in the phone and otherwise).
You can change the file properties to make it 'hidden', but it will still be easily found. There is no way to make a file on a public partition like an SD Card 'secure' in the manner you describe - users will always be able to copy, delete, and potentially change the file.
The best solution to your problem is to look into ways to encrypt your database to record it securely. You won't be able to prevent users from deleting or copying the file, but you should be able to make it difficult for them to read data from it or modify its contents.
For an easy solution, just prefix the db file with a . (like .dbfile). This will hide the file on Linux based systems, including android.
I am assuming that you want to hide the file to prevent users from accidentally deleting/changing it.
SD cards cannot be secured in the fashion you seek.
just name the file start by ."Dot"... ".myFolder/.myfile"
You can create a folder whose name starts with a dot(.) example (.dbfiles) android See these folders as configuration folder and do not show content of these folder in applications like gallery,music player...You can see these folders with advance file explorer like Es File explorer
Sdcard you cant't! Internal app data partition is the place for you.