0

I'm using this functions to move some images and videos to custom folders:

public static void moveFile(File src, File dst) throws IOException {
    FileChannel inChannel = new FileInputStream(src).getChannel();
    FileChannel outChannel = new FileOutputStream(dst).getChannel();
    try {
        inChannel.transferTo(0, inChannel.size(), outChannel);
    } finally {
        if (inChannel != null)
            inChannel.close();
        if (outChannel != null)
            outChannel.close();
    }
    dst.setExecutable(true);
    dst.setReadable(true);
    src.delete();
}

The files are moved correctly and the src files got deleted fine. The problem is that when I try to open the image or video with any gallery it shows black or impossible to play video. So I checked with file manager and saw that files' permissions are wrong. Have you got any suggestions?

Thanks.

twlkyao
  • 14,302
  • 7
  • 27
  • 44
iGio90
  • 3,251
  • 7
  • 30
  • 43
  • What are the original permissions and the permissions now? – twlkyao Jan 05 '14 at 10:58
  • I guess the issue is due to the files are moved to local app data directory and I'm unable to open them with default gallery. Is there any way? – iGio90 Jan 05 '14 at 12:41
  • Yes, if you move the file to app directory, you will have no permission, why don't you move them to public directory(or some directory you created), and what is the reason you move them? – twlkyao Jan 05 '14 at 12:45
  • I'm developing an app that will allows you to put some files such as img, videos and docs in a private folder accessible only with password. Anyway, i just solved it using an hardcoded workaround. I'll move these files to original location, trim media player, play, move them back to priv folders. I'm doing it with onPause and onResume methods but it seems working only if users return back and call onResume. do you know any way to know when the player (gallery or whatever apps play the files) stops playing the files? – iGio90 Jan 05 '14 at 13:11
  • maybe i can use startactivityforresult? well, let's try – iGio90 Jan 05 '14 at 13:16
  • sorry that I can't give any help, I am doing something related, I want to encrypt/decrypt some file, but the process are transparent to upper application, I am still stuck. – twlkyao Jan 05 '14 at 13:19
  • i already pass the crypt/encrypt things. Anyway, onactivityresult also need to call back the app for run. damn :( – iGio90 Jan 05 '14 at 13:26
  • I'm gonna try with a service! – iGio90 Jan 05 '14 at 13:30
  • i tried email you but it says is not existing! – iGio90 Jan 05 '14 at 13:46
  • Sorry, **qishiyao2008@126.com**. – twlkyao Jan 05 '14 at 13:52

0 Answers0