2016-08-22 127 views
0

我們從圖庫中獲取圖像,並將圖像名稱保存到Sqlite中。圖像在應用關閉時從tmp文件夾中刪除

var options = {quality: 75, 
       destinationType : Camera.DestinationType.FILE_URI, 
      sourceType: Camera.PictureSourceType.PHOTOLIBRARY, 
      allowEdit: true, 
      encodingType: Camera.EncodingType.JPEG, 
      targetWidth: 300, 
      targetHeight: 300, 
      popoverOptions: CameraPopoverOptions, 
      saveToPhotoAlbum: true 
      }; 
$cordovaCamera.getPicture(options).then(function (imageData) { 
$scope.ChooseImage = imageData; 
} 

我們將圖片名保存到Sqlite後,我們重新加載了頁面,然後從Sqlite中獲取圖片名稱。我們加入到cordova.file.tempDirectory

var imageGetting = "select * from images_details where taskId='"+$scope.unquid+"'"; 
      $cordovaSQLite.execute(db, imageGetting).then(function(data) { 
                  var GetAllImages = data.rows.length; 
                  for(i=0;i<GetAllImages;i++){ 
                  debugger; 
                  $scope.images.push(cordova.file.tempDirectory + data.rows.item(i).imageUrl); 
                  debugger; 
                  } 
} 

它的工作很好,但是當我們關閉應用程序,tmp文件夾的數據將會消失,因此我們無法顯示圖像。即使tmpfile也被刪除,是否有替代方法來顯示圖像?

回答