+ String filePath = mUploadPath +
+ c.getString(c.getColumnIndex(Images.Media.DISPLAY_NAME));
+ String fullTempPath = FileStorageUtils.getTemporalPath(getAccount().name)
+ + filePath;
+ InputStream inputStream = null;
+ FileOutputStream outputStream = null;
+ if (data == null) {
+ 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();
+ }
+ }
+ }
+