Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.os.Environment;

import java.io.File;

public class Main {
    private static final String DIRECTORY_NAME = "/MyDirectory";

    public static String getPublicDataFolder() {
        StringBuilder publicFolder = new StringBuilder();
        publicFolder.append(Environment.getExternalStorageDirectory()).append(DIRECTORY_NAME);
        File new_dir = new File(publicFolder.toString());
        if (!new_dir.exists()) {
            new_dir.mkdirs();
        }
        return publicFolder.toString();
    }
}