Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Hewlett-Packard Company
 * All rights reserved.
 *
 * This file, its contents, concepts, methods, behavior, and operation
 * (collectively the "Software") are protected by trade secret, patent,
 * and copyright laws. The use of the Software is governed by a license
 * agreement. Disclosure of the Software to third parties, in any form,
 * in whole or in part, is expressly prohibited except as authorized by
 * the license agreement.
 */

import android.content.Context;
import android.content.ContextWrapper;

import java.io.File;

import java.io.IOException;

public class Main {
    public static final String IMAGE_DIR = "imageDir";
    private static final String IMAGE_EXT = ".jpg";

    protected static File createImageFile(Context context, String fileName) throws IOException {

        ContextWrapper cw = new ContextWrapper(context);
        // path to /data/data/yourapp/app_data/imageDir
        File directory = cw.getDir(IMAGE_DIR, Context.MODE_PRIVATE);

        // Create imageDir
        File path = new File(directory, fileName + IMAGE_EXT);
        path.deleteOnExit();

        return path;
    }
}