- File sdCard = Environment.getExternalStorageDirectory();\r
- File file = new File(sdCard.getAbsolutePath() + "/owncloud/" + mAccount.name + mFilePath);\r
- try {\r
- file.getParentFile().mkdirs();\r
- file.createNewFile();\r
- } catch (IOException e) {\r
- e.printStackTrace();\r
- }\r
-\r
- String message;\r
- if (wdc.downloadFile(mRemotePath, file)) {\r
- ContentValues cv = new ContentValues();\r
- cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getAbsolutePath());\r
- getContentResolver().update(\r
+ // download in a temporal file\r
+ File tmpFile = new File(getTemporalPath() + mAccount.name + mFilePath);\r
+ tmpFile.getParentFile().mkdirs();\r
+\r
+ boolean download_result = false;\r
+ File newFile = null;\r
+ if (wdc.downloadFile(mRemotePath, tmpFile)) {\r
+ newFile = new File(getSavePath() + mAccount.name + mFilePath);\r
+ newFile.getParentFile().mkdirs();\r
+ boolean moved = tmpFile.renameTo(newFile);\r
+ \r
+ if (moved) {\r
+ ContentValues cv = new ContentValues();\r
+ cv.put(ProviderTableMeta.FILE_STORAGE_PATH, newFile.getAbsolutePath());\r
+ getContentResolver().update(\r