Hi all,

  I'm trying to transmit files between two phones using WiFi.  After
one of the phones received a image file from the other phone, it save
the file to the SD card, using the dir "/sdcard/MyFiles".  I almost
done this work.

  But, the storage has some problem I think, when the image file is
saved, I can't find it using the Gallery app on the phone
immediately,  I must unmount the SD card and mount it again or do
other thing reprepare the SD card. Then, start the Gallery app again,
the image file is found in my dir.

  The following is my code used to save a file:

public boolean SaveFile(Filedata filedata){ // Filedata has two parts:
"String filename" and "byte[] bytes"
    static final String FILE_DIR = "/sdcard/MyFiles";
    try{
        File FIleDir = new File(FILE_DIR);
        if(FileDir.exists() == false){
            FileDir.mkdir();
        }

        File file = new File(FileDir, filedata.filename);
        file.createNewFile();

        RandomAccessFile fileAccess = new RandomAccessFile (file,
"rw");
        fileAccess.setLength(0);
        fileAccess.write(filedata.bytes);
        fileAccess.close();

    }catch (Exception ex){

        Log.e(TAG, ex.toString());
        return false;
    }

    return true;
}


I don't know what else shoult to do. After quit my app, I want to find
the picture immediately.

Could anyone give some advice?

Thanks,
Best regards,

Wenqi

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to