add File To Media Store - Android Media

Android examples for Media:Media File

Description

add File To Media Store

Demo Code


//package com.java2s;

import android.content.Context;
import android.content.Intent;

import android.net.Uri;

import java.io.File;

public class Main {
    public static final void addFileToMediaStore(final String path,
            Context context) {//w  w  w.j a  v  a2  s  .  co  m
        Intent mediaScanIntent = new Intent(
                Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
        File file = new File(path);
        Uri contentUri = Uri.fromFile(file);
        mediaScanIntent.setData(contentUri);
        context.sendBroadcast(mediaScanIntent);
    }
}

Related Tutorials