Java tutorial
//package com.java2s; //License from project: Open Source License import android.app.Activity; import android.os.Environment; import java.io.File; public class Main { public static File createFile(Activity activity, String name, boolean isThumbnail) { // To be safe, you should check that the SDCard is mounted // using Environment.getExternalStorageState() before doing this. String subDir; String fileType; if (isThumbnail) { subDir = "/thumbnails"; fileType = "thumbnail_"; } else { subDir = "/backgrounds"; fileType = "background_"; } File storageDir = new File(Environment.getExternalStorageDirectory() + "/Android/data/" + activity.getApplicationContext().getPackageName() + subDir); // Create the storage directory if it does not exist if (!storageDir.exists()) { if (!storageDir.mkdirs()) { return null; } } File thumbnailFile; String thumbnailName = fileType + name; thumbnailFile = new File(storageDir.getPath() + File.separator + thumbnailName); return thumbnailFile; } }