diff --git a/android/androidfiledialog.cpp b/android/androidfiledialog.cpp
index f05313e01a9b1204f850401b0e4204adcab40900..a14a241c154ea7c08743ed363e924bcd589b73ee 100755
--- a/android/androidfiledialog.cpp
+++ b/android/androidfiledialog.cpp
@@ -72,11 +72,14 @@ QString AndroidFileDialog::ResultReceiver::uriToPath( QAndroidJniObject uri )
             QString cacheFile = cacheDir.filePath(displayName);
             qDebug() <<"cachefile: " << cacheFile;
             QFile file(cacheFile);
-            if(file.open(QIODevice::WriteOnly)){
-                file.write((const char*)realdata,iconSize);
+            if(realdata != nullptr){
+                if(file.open(QIODevice::WriteOnly)){
+                    file.write((const char*)realdata,iconSize);
+                }
+                qDebug() <<"wrote file " << cacheFile;
+                return cacheFile;
             }
-            qDebug() <<"wrote file " << cacheFile;
-            return cacheFile;
+            return QString( "null" );
         }
     }
 }