나는 이미지를 캡처 할 수있는 비디오 컨트롤이있는 블랙 베리 앱을 개발 한 다음 루트 디렉토리에 이미지를 저장하고 원하는 이름으로 이미지를 저장합니다. 화면 ... 다시 캡처 버튼을 클릭하면 다시 한번 이미지를 캡처하고 이전 이미지를 삭제하고 파일 연결을 사용하여 같은 경로에 같은 이름으로 새 이미지를 저장합니다. 내 문제는 에뮬레이터에서 잘 작동합니다. 그러나 장치에서 테스트 할 때 새 이미지를 저장하기 위해 이전 이미지를 삭제하려고하면 오류가 발생합니다 .. "net.rim.device.api.io.file.fileioexception : 파일이 현재 사용 중입니다" .. @juanmabaiu 이것은 잡아 가고 장치에서 테스트 할 때 예외를 throw하는 기능입니다, 파일 연결을 사용하여 SD 카드의 파일을 삭제할 수 있습니다 - Blackberry
이 @arhimed .. 저를 도와주세요.
public void fieldChanged(final byte[] _raw)
{
try
{
flag ++;
// Create the connection to a file that may or
// may not exist.
FileConnection file = (FileConnection)Connector.open(FILE_NAME + "_front" + EXTENSION);
// If the file exists, increment the counter until we find
// one that hasn't been created yet.
while(file.exists())
{
file.delete();
file = (FileConnection)Connector.open(FILE_NAME + "_front" + EXTENSION);
}
//FileConnection file_temp = (FileConnection)Connector.open(FILE_NAME + "tempimg" + EXTENSION);
//file_temp.delete();
// We know the file doesn't exist yet, so create it
file.create();
// Write the image to the file
OutputStream out = file.openOutputStream();
out.write(_raw);
// Close the connections
out.close();
file.close();
//Dialog.inform("Saved to " + FILE_NAME + "_front" + EXTENSION);
}
catch(Exception e)
{
home.errorDialog("ERROR " + e.getClass() + ": " + e.getMessage());
Dialog.inform("File not saved this time");
}
}
파일을 저장하거나 삭제 한 후에 스트림을 닫아야합니다. –
위의 코멘트에서 Arhimed가 말한 것을 시도해보십시오. 문제가 해결되지 않으면 코드를 추가하십시오. –
안녕하세요 arhimed 및 juanmabaiu .. 모든 것이 코드에서 잘됩니다. 에뮬레이터에서 완벽하게 작동합니다. 장치에서 테스트했을 때 오류가 표시됩니다 .. –