- try {
- inputStream = getContentResolver().openInputStream(uri);
- File cacheFile = new File(fullTempPath);
- cacheFile.createNewFile();
- outputStream = new FileOutputStream(fullTempPath);
- byte[] buffer = new byte[4096];
-
- int count = 0;
-
- while ((count = inputStream.read(buffer)) > 0) {
- outputStream.write(buffer, 0, count);
- }
-
- outputStream.close();
- inputStream.close();
-
- data = fullTempPath;
- }catch (Exception e) {
- if (inputStream != null) {
- try {
- inputStream.close();
- } catch (Exception e1) {
-
- }
- }
-
- if (outputStream != null) {
- try {
- outputStream.close();
- } catch (Exception e1) {
-
- }
- }
-
- if (fullTempPath != null) {
- File f = new File(fullTempPath);
- f.delete();
- }
- }
+ CopyTmpFileAsyncTask copyTask = new CopyTmpFileAsyncTask(this);
+ Object[] params = { uri, filePath };
+ try {
+ data = copyTask.execute(params).get();
+ } catch (ExecutionException e) {
+ Log_OC.e(TAG, "ExecutionException " + e);
+ } catch (InterruptedException e) {
+ Log_OC.e(TAG, "InterruptedException " + e);
+ }