User42590
User42590

Reputation: 2521

File is not opening from Assets in Android

I am trying to read images from Assets.In Assets i have been using a-z folders and these folders contains images with the starting name of folder like if there is folder named YImages then images in this folder image's names are also starting with Y word.

I am using this function to get images from Assets:

        try {
        pics = Drawable
                .createFromStream(
                        getAssets().open(
                                imageFolder + wordString.get(index)
                                + ".jpg"), null);

        picture.setBackgroundDrawable(pics);
        picture.refreshDrawableState();


    } catch (IOException e) {

        e.printStackTrace();
    }

Upvotes: 0

Views: 375

Answers (2)

GrIsHu
GrIsHu

Reputation: 23638

Just change all the image file name with the small letters do not use the capital letter in image file name . i.e badger_thumbnail.jpg,badge_thumbnail.jpg,year.jpg like this. Also keep in mind that there is no space in your any image name.

Upvotes: 1

Rajitha Siriwardena
Rajitha Siriwardena

Reputation: 2759

Theres a space at your image path. java.io.FileNotFoundException: yImages/ Year.jpg Try trimming the File name.

Upvotes: 1

Related Questions