Created createNomedia method

This commit is contained in:
Data5tream 2015-12-20 13:29:08 +01:00
parent 1868103380
commit 9e191a2646

View file

@ -6,6 +6,7 @@ import android.os.Environment;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
public class BitmapUtils {
public static String getSavePath() {
@ -34,6 +35,7 @@ public class BitmapUtils {
public static void saveToFile(String filename, Bitmap bmp) {
try {
createNomedia();
File myDir = new File(getSavePath());
boolean res = myDir.mkdirs();
@ -51,4 +53,16 @@ public class BitmapUtils {
String status = Environment.getExternalStorageState();
return status.equals(Environment.MEDIA_MOUNTED);
}
private static boolean createNomedia() {
//Returns true if .nomedia was created/already existed and false if not
try {
File cacheDir = new File (getSavePath());
cacheDir.mkdirs();
File nomediaFile = new File (getSavePath() + "/.nomedia");
if (!nomediaFile.isFile()) return nomediaFile.createNewFile();
} catch (IOException e) {
}
return false;
}
}