Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

Show thumbnail and text using listview and SQLite

0

44 views

I have a folder on sdcard with videos. I created a SQLite database with video attributes(columns). I need to show video thumbnail with text and time in a listview. How do i query for the videos in that folder and display them with the database columns in the listview. I saw a sample but its using the mediastore and i dont want to add my videos to the mediastore.

String[] thumbColumns = { MediaStore.Video.Thumbnails.DATA,
            MediaStore.Video.Thumbnails.VIDEO_ID };

    String[] mediaColumns = { MediaStore.Video.Media._ID,
            MediaStore.Video.Media.DATA,
            MediaStore.Video.Media.DESCRIPTION,
            MediaStore.Video.Media.MIME_TYPE,
            MediaStore.Video.Media.DATE_ADDED };


    cursor = managedQuery(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
            mediaColumns, null, null, null);

    ArrayList<VideoViewInfo> videoRows = new ArrayList<VideoViewInfo>();
    if (cursor.moveToFirst()) {
        do {
            VideoViewInfo newVVI = new VideoViewInfo();

            int id = cursor.getInt(cursor
                    .getColumnIndex(MediaStore.Video.Media._ID));

            Cursor thumbCursor = managedQuery(
                    MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI,
                    thumbColumns, MediaStore.Video.Thumbnails.VIDEO_ID
                            + "=" + id, null, null);
            if (thumbCursor.moveToFirst()) {
                newVVI.thumbPath = thumbCursor.getString(thumbCursor
                        .getColumnIndex(MediaStore.Video.Thumbnails.DATA));
                Log.v(QUEUE_LOG, "Thumb " + newVVI.thumbPath);
            }
            newVVI.filePath = cursor.getString(cursor
                    .getColumnIndexOrThrow(MediaStore.Video.Media.DATA));

            newVVI.date_taken = cursor
                    .getString(cursor
                            .getColumnIndexOrThrow(MediaStore.Video.Media.DATE_ADDED));

            newVVI.mimeType = cursor
                    .getString(cursor
                            .getColumnIndexOrThrow(MediaStore.Video.Media.MIME_TYPE));
            Log.v(QUEUE_LOG, "Mime " + newVVI.mimeType);
            videoRows.add(newVVI);
        } while (cursor.moveToNext());
    }
    myListview.setAdapter(new VideoGalleryAdapter(this, videoRows));

any help...

asked June 23, 2011 12:43 pm CDT
posted via StackOverflow

0 Answers

Be the first to answer this question

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect

Preview
Similar questions