Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.Context;
import android.content.Intent;
import android.database.Cursor;

import android.provider.MediaStore.Video.VideoColumns;

public class Main {
    public static String getVideoPath(Context context, Intent data) {
        Cursor cursor = context.getContentResolver().query(data.getData(), null, null, null, null);
        if (cursor != null && cursor.moveToNext()) {
            String filePath = cursor.getString(cursor.getColumnIndex(VideoColumns.DATA));
            return filePath;
        } else if (data != null && data.getData() != null) {
            return data.getData().getEncodedPath();
        }
        return null;
    }
}