Posted in Cordova/PhoneGap

[Cordova] Display a Loading modal with GIF file using Onsen UI

Normally, we can display a Loading modal with icon in Onsen UI (ref Onsen UI document). But how about Loading modal with GIF file ?

It is very simple, please find the demo below:

You also can find above example code at my_codepen

Issue refer here

Like and share if it is helpful 🙂

Posted in Uncategorized

[Cordova] How to preview PDF file inside Cordova project


Hi all, I faced this challenge for my tasks list. After searching a lot on Internet with various solutions:

  • Using InAppBrower: this plugin can open PDF for preview but it will open a certain PDF reader application on device not inside our Cordova project
  • PDFObject: hmmm, I tried use it but I faced compile error about import it into my project, I did not fix that issue because of time limitation.

Finally, I found the solution which solved my challenge 🙂 (it saved my life 🙂 ).

Below is result:


About the detail, please follow steps of the “example” at my github

I preferred that solution at sayanee’s github. Thank him very much 🙂

You also install that plugin by npm (Ref detail at here):

npm install angular-pdf

Hope it is helpful 🙂

Posted in Cordova/PhoneGap

[Cordova] How to download a file


To download a file from given URL, we need the cordova-plugin-file-transfer plugin. You also install this plugin by command:

cordova plugin add cordova-plugin-file-transfer

Then, use below code:

 function downloadFile(downloadedFileName, downloadLink) {

var fileURL;
if (monaca.isAndroid === true) {
var androidDownloadPath = ‘/storage/emulated/0/path/to/’;
fileURL = androidDownloadPath + downloadedFileName;
} else {
var iosDownloadPath = cordova.file.documentsDirectory;
fileURL = iosDownloadPath + downloadedFileName;
var uri = encodeURI(downloadLink);
processDownloadFile(uri, fileURL);


function processDownloadFile(uri, fileURL) {
var encodedFileURL = encodeURI(fileURL);
var fileTransfer = new FileTransfer();
function(entry) {
console.log(“Download complete ! Place of downloaded file: ” + entry.toURL() + ” – Source: ” + uri);
function(error) {
console.error(“error source ” + error.source + ” – download error target ” + + ” – upload error code” + error.code);
false, {
headers: {
“Authorization”: “Basic false headers”

Posted in Android Programming, Cordova/PhoneGap, iOS Programming, Mobile_Tips

[Cordova] Tips: How to delete a file


Actually, it is very easy and simple because you can use the cordova-plugin-file

You can download the file plugin with command:

cordova plugin add cordova-plugin-file

Demo code:

var path = "file:///storage/emulated/0";
var filename = "myfile.txt";

window.resolveLocalFileSystemURL(path, function(dir) {
	dir.getFile(filename, {create:false}, function(fileEntry) {
                  // The file has been removed succesfully
                  // Error deleting the file
                 // The file doesn't exist

Hope it is useful🙂