From cb34f9d50efa8c579adb596cde8c88102ce8043c Mon Sep 17 00:00:00 2001 From: Equip de Desenvolupadors de PBE Date: Sun, 16 Dec 2012 17:28:57 +0000 Subject: [PATCH] Bug file duplicate fixed --- AndroidManifest.xml | 2 -- src/com/upc/pbe/upcnews/VideoActivity.java | 10 +++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index daf2779..ac2c73e 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -24,8 +24,6 @@ - - diff --git a/src/com/upc/pbe/upcnews/VideoActivity.java b/src/com/upc/pbe/upcnews/VideoActivity.java index aef0aa1..b999ae2 100644 --- a/src/com/upc/pbe/upcnews/VideoActivity.java +++ b/src/com/upc/pbe/upcnews/VideoActivity.java @@ -6,6 +6,7 @@ import io.vov.vitamio.widget.MediaController; import io.vov.vitamio.widget.VideoView; import java.io.BufferedInputStream; +import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.net.MalformedURLException; @@ -230,7 +231,14 @@ public class VideoActivity extends Activity { // Iniciem la connexi� i creem els Streams try { - FileOutputStream out = new FileOutputStream(filePath + fileName,true); + int index = 0; + String newFileName = fileName; + while(new File(filePath + newFileName).exists()) + { + newFileName = fileName + index++; + } + fileName = newFileName; + FileOutputStream out = new FileOutputStream(filePath + fileName); BufferedInputStream in = new BufferedInputStream(urls[0].openStream()); Log.d(TAG, "\nDescarregant: \n"); Log.d(TAG, ">> URL: " + urls[0]); -- libgit2 0.22.2