Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.File;

import java.io.IOException;
import android.content.Context;

import android.os.Environment;

public class Main {
    private static final String APP_DIR = "dailyselfie/pictures";

    public static String getBitmapStoragePath(Context context) {
        String bitmapStoragePath = "";
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
            try {
                String root = context.getExternalFilesDir(null).getCanonicalPath();
                if (null != root) {
                    File bitmapStorageDir = new File(root, APP_DIR);
                    bitmapStorageDir.mkdirs();
                    bitmapStoragePath = bitmapStorageDir.getCanonicalPath();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        return bitmapStoragePath;
    }
}