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.os.Environment;
import android.util.Log;

public class Main {
    public static final String MEDIA_PUBLIC_FOLDER_NAME = "AR.Drone";
    private static final String TAG = "FileUtils";

    /**
     * Retrieves FreeFlight media directory.
     * May return null.
     * @param context
     * @return Media directory to store the media files or null if sd card is not mounted.
     */
    public static File getMediaFolder(Context context) {
        File dcimFolder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);

        if (dcimFolder == null) {
            Log.w(TAG, "Looks like sd card is not available.");
            return null;
        }

        File mediaFolder = new File(dcimFolder, MEDIA_PUBLIC_FOLDER_NAME);

        if (!mediaFolder.exists()) {
            mediaFolder.mkdirs();
            Log.d(TAG, "Root media folder created " + mediaFolder);
        }

        return mediaFolder;
    }
}