I'm currently trying to figure out how to set a custom image for a external storage directory I'm creating some time in the app. If you're probably using a file browser like ES File Explorer you will see that some apps like WhatsApp but also smaller projects have an extra little picture or app logo added to their folder.
Is this possible to set by code?
You can't set one that other apps use. There's no such concept as an image for a directory. Inside your own app you can do whatever you want, you have to write any file explorer yourself.
Related
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 currently developing an app in Android Studio for Android TV on a mac. Ultimately I want to load local image files as card images in a VerticalGridFragment where a card id and an image filename have matching numbers. For the sake of prototyping, right now I'm just trying to set up best practices (as a complete novice) with a single 1.jpg file that will appear on every card.
I'm using the included Android TV emulator and assume I shouldn't attempt to use access or make use of any OSX file system. So my two questions are:
While I'm prototyping and trying to get 1.jpg to be the image for
each card, where should I place this file in a manner that I can
access using a file path string for internal storage, such as /root/1.jpg
which I can later change to /root/$.jpg where $ is a dynamic id
associated with each card. This needs to satisfy both the emulator
being able to access the file, a device being able to access the file when the app is finished, and me being able to place files there
from my host os while prototyping.
A follow-on question. When the app is finished I obviously won't be
relying on manually placing image files. Will the solution to the
above also provide a straightforward means of saving images to this
directory on a device?
Thanks.
Ok, I think I've got my head around this now:
Inside Android Studio, there's a Monitor utility in which there's a File Explorer. Using this, you can browse, and save to the directory structure that the emulator's using.
Most importantly, there is a standard assigned directory for apps to save and open from on internal storage. It can be found in the file browser at /data/data/com.applicationname/files/
From any app, it can be referenced for saving to or opening from using getFilesDir(), which answers question 2.
I want to show my android Application data directory on external storage like shown in image (with icon).
I am currently using simple directory to store files.
please give your thoughts on this .
thanks in advance ..
http://i.stack.imgur.com/fQbtH.png
All folders on Android are normal folders, ES File Explorer not uses any recognition system, people associates folders and every association is sent to ES File Explorer's database and majority of associations wins and finally folder is assigned with icon.
I know the following happens in Windows [desktop]:
the system has an icon for each extension, and a default one for new ones.
When a new program is installed, it saves its icons to its extensions in the system [ex. upgrading Word 2007 to 2010 changes the icons for .docx files]
Now I want to know how to get those icons in android. I'm not sure if it follows the same scenario, BUT, i have a file explorer app which displays those icons. From my use of it, i know that those icons cannot be hard coded [except for the folder icon]. For example, after installing Tango, its icon took over the .ini files
My question is, How to get those icons? I'm kinda doing a file explorer app [that serves certain needs no other app does]
Android doesn't provide that functionality. You have either hard-code drawables for most-used file types into your application or download them from Internet.
You'd have to create your own icons, scan for the file types found, match those to some internal list and display the according icon (Drawable) in a Imageview in your ListView. Assuming you are using a ListView to display the files found here ofcourse.
I'm planning to release a nice clock widget and I'd like to include a pretty wallpaper with it (want to do this because previously got some comments like "can i get the matching wallpaper? ;)")
So I tried to google on how to put some image file inside apk so that it would appear in wallpapers selection list after installation. I mean the list which appears when doing Home=>Menu=>Wallpaper=>Wallpaper Gallery or Pictures - whatever.
So far didn't find any hints, so decided to try to ask here.
Any hints on how to do that?
You could package the wallpaper in res/raw, and then when your app fires up for the first time, attempt to copy it to the sdcard directory /media/pictures.
You should be using methods such as getExternalStorageDirectory or getExternalStoragePublicDirectory (depending on the API level) to open the file.
http://developer.android.com/guide/topics/data/data-storage.html#filesExternal