Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.File;

import android.content.Context;

import android.provider.MediaStore;

public class Main {
    public static void deleteSinglePicture(Context ctx, String path) {
        String params[] = new String[] { path };
        ctx.getContentResolver().delete(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                MediaStore.Images.Media.DATA + " LIKE ?", params);
        File file = new File(path);
        File pFile = file.getParentFile();
        if (pFile != null && pFile.isDirectory()) {
            File files[] = pFile.listFiles();
            if (files == null || files.length == 0) {
                pFile.delete();
            }
        }
    }
}