V-rund Puro-hit
V-rund Puro-hit

Reputation: 5534

create folder with app icon instead of default folder icon

I want to add my app Icon to created folder instead of default folder icon.

I know i can create folder with following code.

String extr = Environment.getExternalStorageDirectory().toString();
File mFolder = new File(extr + "/My Application/Downloads");
if (!mFolder.exists()) {
    mFolder.mkdirs();
}

By doing this, i'm getting following result.

enter image description here

but what i want is..

enter image description here

I have searched a lot, but no luck. can anyone help me out?

Thank you.

Upvotes: 5

Views: 905

Answers (3)

Farid Haq
Farid Haq

Reputation: 4199

After creating new directory you have to declare resource directory in your gradle file so that android studio can recognize new resource directory.

More information please refer https://developer.android.com/studio/write/add-resources

Upvotes: 0

Oleksii Zghurskyi
Oleksii Zghurskyi

Reputation: 4365

Customization of folder icon is OS dependent.

  • On Windows you will use Desktop.ini file to assign a custom icon or thumbnail image to a folder. To simplify working with Desktop.ini you can use ini4j. Basically, you will need to create Desktop.ini in the folder, that you want to customize and specify path to the icon there. (Here is similar question)
  • On Mac OS the process is different. There are ways to access icons (for example, FileView or FileSystemView, also Quaqua). However I haven't found a way to set folder icon programmatically with Java.

Note: I assumed, that you want to add icon to arbitrary folder and not your app laucher.

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006819

Directories do not have icons, and so whatever app or tool your screenshot is from is adding that. You would have to ask the developers of that app or tool what algorithm they are using to determine the icon to show.

Upvotes: 8

Related Questions