Commit 57a0bbbf authored by Donald's avatar Donald Committed by GitHub

Merge pull request #376 from Sysmain/dev

NPE somthing
parents ec12d74b bedaf41a
......@@ -426,7 +426,7 @@ public class Album implements Serializable {
private boolean moveMedia(Context context, String source, String targetDir) {
File from = new File(source);
File to = new File(targetDir);
File to = new File(targetDir, from.getName());
return ContentHelper.moveFile(context, from, to);
......@@ -189,17 +189,18 @@ public class ContentHelper {
* Move a file. The target file may even be on external SD card.
* @param source The source file
* @param targetDir The target Directory
* @param target The target Directory
* @return true if the copying was successful.
public static boolean moveFile(Context context, @NonNull final File source, @NonNull final File targetDir) {
// First try the normal rename.
File target = new File(targetDir, source.getName());
public static boolean moveFile(Context context, @NonNull final File source, @NonNull final File target) {
// the param "target" is a file.
// File target = new File(target, source.getName());
// First try the normal rename.
boolean success = source.renameTo(target);
if (!success) {
success = copyFile(context, source, targetDir);
success = copyFile(context, source, target);
if (success) {
success = deleteFile(context, source);
......@@ -17,7 +17,7 @@ import java.util.regex.Pattern;
public class StringUtils {
public static String getMimeType(String path) {
String extension = path.substring(path.lastIndexOf('.')+1);
String extension = path.substring(path.lastIndexOf('.')+1).toLowerCase();
return MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
<?xml version="1.0" encoding="utf-8"?>
<external-path name="external_files" path="."/>
<root-path name="external_files" path=""/>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment