Cannot Resolve Symbol Length

I want to retrieve a list of images from SQLite.

This is my 'getImage()' method

    public List<byte[]> getImage(int i) {
    List<byte[]> list = new ArrayList<>();
    String selectImage = "SELECT VocabImage FROM Vocab WHERE VocabTopic =" + i;
    Cursor c = database.rawQuery(selectImage, null);
    if(c.moveToFirst())
        do{
            list.add(c.getBlob(c.getColumnIndex("VocabImage")));
        }while(c.moveToNext());

    c.close();
    return list;
}

This is my java class where I want to call my getImage() method. But there is an error saying that it cannot resolve symbol 'length' in (data.length) in the BitmapFactory line. Anyone has any idea how to solve this? Thank you.

 Intent intent = getIntent();

 int topicId = intent.getIntExtra("SelectedTopicId", 1);

 databaseAccess.open();

 List<byte[]>data = databaseAccess.getImage(topicId);

 Bitmap image = BitmapFactory.decodeByteArray(data, 0, data.length);

 imageView.setImageBitmap(image);
2

2 Answers

Bitmap image = BitmapFactory.decodeByteArray(data, 0, data.length);

change to

Bitmap image = BitmapFactory.decodeByteArray(data.get(position), 0, data.get(position).length);  // pass position for which you want length.
2

you need to change like this: list.get(0).length for get image at index 0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest