Question

I captured a video with Mediarecorder, inserted it to mediastore then updated the content values of that video in next screen. But its changing the DESCRIPTION on all videos in the list, i only want to change the current recorded video. Here are some code:

ContentValues values = new ContentValues(1);
        //long current = System.currentTimeMillis();


        //values.put(MediaStore.Video.Media.DATE_ADDED, (int) (current / 1000));
        //values.put(MediaStore.Video.Media.MIME_TYPE, "video/mp4");
        values.put(MediaStore.Video.Media.DESCRIPTION, edtext.getText().toString());
        //values.put(MediaStore.Video.Media.DATA, videoFile.getAbsolutePath());
        ContentResolver contentResolver = getContentResolver();
        Uri base = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
        contentResolver.update(base, values,null,null);

        sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, base));

I'm using this in listview:

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.caption = cursor
                    .getString(cursor
                            .getColumnIndexOrThrow(MediaStore.Video.Media.DESCRIPTION));

How do i fix this and How do i make this a private folder for my app?

Was it helpful?

Solution

Where you do this:

contentResolver.update(base, values,null,null);

you are basically asking it to change everything (and the system is doing exactly what you asked for). What you will need to to do is add the file using the media scanner as you are already doing then query for the file (I'm thinking you could just use the DATE_ADDED column and search for any videos added after just before you sent the intent) and then use the URI you get from the query to in the update call (instead of base).

Let me know if that works.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top