mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
Created createNomedia method
This commit is contained in:
parent
1868103380
commit
9e191a2646
1 changed files with 14 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue