How to retrieve SQLite database has BLOB type to text in cordovaSQLite


#1

I have a lot of .sqlite files, all the text have been zipped and save as blob image. My brother use this to develop an app in iPhone. But know I want to use it with ionic framework.
Can anyone show me how to retrieve all the binary blob to unzipped and readable text in ionic?
Thanks for any help.


#2

You’re best off using the NGCordova SQLITE plugin and then just loop through the result and do whatever you want.
http://ngcordova.com/docs/plugins/sqlite/ - to unzip first just look at http://ngcordova.com/docs/plugins/zip/ - once you have your sqlite back essentially it’s like:

var query = "SELECT * FROM Visits";
      $cordovaSQLite.execute(db, query, []).then(function (res) {
        if (res.rows.length > 0) {
          for (var i = 0; i < res.rows.length; i++) {
            console.log("SELECTED -> " + res.rows.item(i).Name + " " + res.rows.item(i).Details);
            $scope.Visits.push(res.rows.item(i));
          }
        } else {
          console.log("No results found");
        }
      }, function (err) {
        console.error(err);
      });

#3

Thanks for your suggestion. But now I have a sqlite file. How can I open it in my ionic app. I have follow this tutorial Prepopulated SQLite Databases in Ionic but can’t work.
Do I need to copy the prepopulated databases to the app? Why don’t we open and use it?
Can I use this http://ngcordova.com/docs/plugins/sqlite/ instead?
Thanks you!