File BlackBerry曲线存储不足异常

File BlackBerry曲线存储不足异常,file,blackberry,download,storage,File,Blackberry,Download,Storage,我有一个应用程序可以下载大约6mb的视频文件 我试图在Blackberry Curve 9360上运行这个应用程序,它有32mb的“媒体”存储空间 有时,此应用程序运行并能够毫无问题地下载视频,但有时下载过程中途失败,出现IO异常:“文件系统上没有足够的可用内存来完成此操作” 在它以这种方式失败后,我可以打开黑莓桌面软件并检查文件部分,看看设备是否确实报告32/32MB已满 如果我用alt shift del重新启动设备并再次打开blackberry桌面软件,使用的空间将缩小到仅5-6/32mb

我有一个应用程序可以下载大约6mb的视频文件

我试图在Blackberry Curve 9360上运行这个应用程序,它有32mb的“媒体”存储空间

有时,此应用程序运行并能够毫无问题地下载视频,但有时下载过程中途失败,出现IO异常:“文件系统上没有足够的可用内存来完成此操作”

在它以这种方式失败后,我可以打开黑莓桌面软件并检查文件部分,看看设备是否确实报告32/32MB已满

如果我用alt shift del重新启动设备并再次打开blackberry桌面软件,使用的空间将缩小到仅5-6/32mb

有时此时我可以运行我的应用程序,并使其成功下载,但有时它再次给我相同的存储满错误。我能注意到的唯一一件事似乎是,它可能会影响下载是否失败,那就是下载总共需要多长时间(即,它在wifi上成功,在3g信号良好的情况下失败,但在3g信号较差的情况下失败,但这充其量只是个传闻)

我在几个不同的黑莓设备上使用过这个完全相同的应用程序,包括其他几个存储大小相同的Curve设备,以前从未遇到过这个问题

我的问题是:有没有人见过BlackBerry curve设备的行为会导致它报告错误的存储空间,并通过重新启动进行修复

这段下载代码是否有可能导致这种行为

class DownloadThread extends Thread {
    public void run()
    {
        HttpConnection httpConn = null;
        InputStream is = null;
        try{

            httpConn = (HttpConnection)Connector.open(videoUrl + ";interface=wifi");
            is = httpConn.openInputStream();
        }catch(IOException e){
            try{
                httpConn = (HttpConnection)Connector.open(videoUrl);
                is = httpConn.openInputStream();
            }catch(IOException ioe){
                System.out.println("891: "+e.toString());
            }
        }


         try{

         if (!videoFconn.exists())
             videoFconn.create();
         else{
             videoFconn.delete();
             videoFconn.create();
         }
         OutputStream os = videoFconn.openOutputStream();
         lengthOfWebFile = httpConn.getLength();
         total = 0;
         System.out.println("##################### length of web file = " + lengthOfWebFile + " #################");
         byte data[] = new byte[256];
         while ((count = is.read(data)) != -1) {

             total += count;
             progress = (int)(total*100/lengthOfWebFile);
             if(model.getValue() < progress){
                 UiApplication.getUiApplication().invokeLater(new Runnable()
                 {
                     public void run()
                     {
                         EmbeddedMediaScreen.this.model.setValue(progress);
                     }
                 });
             }
             //write this chunk
             os.write(data, 0, count);

             Thread.yield();
         }
         os.flush();
         os.close();
         is.close();
         httpConn.close();
         lengthOfLocalFile = videoFconn.fileSize();
         System.out.println("###################### Local Length =  " + lengthOfLocalFile + "#####################");



         if(lengthOfLocalFile == lengthOfWebFile){
             amDownloading = false;
             startVideo();
         }else{
             downloadVideo();
         }
         }catch(FileNotFoundException fnf){

         }catch(IOException e){
             //ScreenSaverActivity.errorDialog("975: "+e.toString());
             System.out.println("980: "+e.toString());
             //e.printStackTrace();
         }catch(NullPointerException npe){
             System.out.println("983: "+npe.toString());
         } /*catch (InterruptedException e) {
                // TODO Auto-generated catch block
                System.out.println(e.getMessage());
            }*/
     }

     public synchronized void postProgress(final int p){
         UiApplication.getUiApplication().invokeLater(new Runnable()
         {
             public void run()
             {
                             //Set the progress bar
                 EmbeddedMediaScreen.this.model.setValue(p);
             }
         });
     }

}
类下载线程扩展线程{
公开募捐
{
HttpConnection httpConn=null;
InputStream=null;
试一试{
httpConn=(HttpConnection)连接器。打开(videoUrl+“接口=wifi”);
is=httpConn.openInputStream();
}捕获(IOE异常){
试一试{
httpConn=(HttpConnection)Connector.open(videoUrl);
is=httpConn.openInputStream();
}捕获(ioe异常ioe){
System.out.println(“891:+e.toString());
}
}
试一试{
如果(!videoFconn.exists())
videoFconn.create();
否则{
videoFconn.delete();
videoFconn.create();
}
OutputStream os=videoFconn.openOutputStream();
lengthOfWebFile=httpConn.getLength();
总数=0;
3.系统。输出。系统。输出。印刷LN(“(“你们们)系统。系统。系统。输出。系统。系统。输出。印刷LN(“你们们)系统。系统。系统。系统。输出。系统。输出。印刷LN(“你们们)民民民民民方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方""""",;
字节数据[]=新字节[256];
而((计数=is.read(数据))!=-1){
总数+=计数;
进度=(整数)(总计*100/长文件);
if(model.getValue()
上面的代码遗漏了很多变量,因此我们无法测试您的代码从未见过这样的情况,但我对您的代码有两点看法:首先,在http连接中,总长度通常是未知的。不要依赖这些数据。其次,我看到你用invokeLater生成了太多的Runnable。尝试仅每隔一段时间刷新。另一个提示:使用
videoFconn.availableSize()
检查可用空间并记录。我知道httpConn给我的长度是准确的,因为我可以将它与文件中的总字节数进行比较。我会尝试退出一些runnables,只会每5%或更多的时间发布一次进度。谢谢你的建议。