Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 914211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:40:57+00:00 2026-05-15T17:40:57+00:00

After having solved every of my previous issues to get the code running for

  • 0

After having solved every of my previous issues to get the code running for retrieving videos from the sdcard and displaying them in the GridView, I still cannot see the videos. I don’t know what I have done wrong that they won’t show and the array isn’t passed on.

If someone could help me out, please, because I really haven’t got a clue what’s wrong… :(( Thank you…

This is the java file that tries to retrieve and display the videos from the sdcard in the GridView:

package com.mobilevideoeditor.moved;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.VideoView;




public class EditGalleryView extends Activity {
    Uri[] vidUris;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.videogrid);

        GridView vGrid=(GridView) findViewById(R.id.vgrid);
        vGrid.setAdapter(new VideoAdapter(this));

        Uri uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;

        Log.d("EditGalleryView", "uri:"+uri);
        String[] projection = {
                MediaStore.Video.Media.DESCRIPTION,
                MediaStore.Video.Media.DATA  
    };

        Cursor c = this.managedQuery(uri, projection, null, null,
                MediaStore.Video.Media.DATE_ADDED);
                         Log.d("EditGalleryView", "vids available:" +c.getCount());

                         ArrayList<Uri> experimentVids = new ArrayList<Uri>();


                             if (c.getCount() != 0) {
                                 c.moveToFirst();
                                 experimentVids.add(Uri.parse(c.getString(1)));
                                 while (c.moveToNext()) {
                                         experimentVids.add(Uri.parse(c.getString(1)));

                                  }
                      }
                             Log.d("ClassName", "experimentVids.length:" +experimentVids.size());
                                                  if (experimentVids.size() != 0) {
                                                    vidUris = new Uri[experimentVids.size()];
                                                      for (int i = 0; i < experimentVids.size(); i++) {
                                                          vidUris[i] = experimentVids.get(i);
                                                      }
                                                      Log.d("EditGalleryView", "vidUris:"+vidUris.length);
                                                  }
                                              }


    public class VideoAdapter extends BaseAdapter {
        private Context mContext;

        public VideoAdapter(Context c) {
            mContext = c;
        }

        public int getCount() {
            //return mThumbIds.length;
           if(vidUris!=null){
            return vidUris.length;}
        return 0;
        }


        public Object getItem(int position) {
            //return null;
            return position;
        }

        public long getItemId(int position) {
            //return 0;
            return position;
        }

        // create a new ImageView for each item referenced by the Adapter
        public View getView(int position, View convertView, ViewGroup parent) {
           VideoView videoView;
            if (convertView == null) {  // if it's not recycled, initialize some attributes
                videoView = new VideoView(mContext);
                videoView.setVideoURI(vidUris[position]);
                videoView.setLayoutParams(new GridView.LayoutParams(85, 85));
               //videoView.setScaleType(VideoView.ScaleType.CENTER_CROP);
                videoView.setPadding(8, 8, 8, 8);
            } else {
                videoView = (VideoView) convertView;
            }

          //  imageView.setImageResource(mThumbIds[position]);
            return videoView;
        }

       /* // references to our images
        private Integer[] mThumbIds = {
                R.drawable.sample_2, R.drawable.sample_3,
                R.drawable.sample_4, R.drawable.sample_2,
                R.drawable.sample_6, R.drawable.sample_3,
                R.drawable.sample_4, R.drawable.sample_1,

        };*/

    }   

}

Force close Error – ISSUE SOLVED


App Disappearance – ISSUE SOLVED


Array Issue – ISSUE SOLVED

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:40:57+00:00Added an answer on May 15, 2026 at 5:40 pm

    Make vidUris a member of the EditGalleryView class. Also I think there is a toArray method on ArrayList that will return an array of elements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.