Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: LGPL 

import android.content.Context;
import android.database.Cursor;
import android.net.Uri;

import android.provider.MediaStore;

public class Main {
    private static String[] mediaColumns = { MediaStore.Video.Media._ID };

    private static long getFileId(Context context, Uri fileUri) {

        Cursor cursor = context.getContentResolver().query(fileUri, mediaColumns, null, null, null);

        if (cursor.moveToFirst()) {
            int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Video.Media._ID);
            int id = cursor.getInt(columnIndex);
            return id;
        }

        return 0;
    }
}