Tib
Tib

Reputation: 2631

Best way to store json object from rest api in an offline cordova app

I'm building an AngularJS application wrapped with Cordova for Android and iOS. All my datas come from my rest API.

I have urls like my.api/groups/1/items to get the list of items

 [
    {
        id: 5,
        type: "foo",
        title: "Item 5",
        group: 1,
        body: "<p>Some content</p> ",
        img: "http://my.website/images/item5.jpg"
    },
    {
        id: 6,
        ...
    }
]

and my.api/items/5 to get a specific item

{
    id: 5,
    type: "foo",
    title: "Item 5",
    group: 1,
    body: "<p>Some content</p> ",
    img: "http://my.website/images/item5.jpg"
}

I retrieve my datas with restangular and it works perfectly

Restangular.one('group', id).getList('items').then(function(data){
  $scope.items = data;
});

Now I want that datas be available offline and refreshed time to time. Localstorage is not possible because I ll have +5MB of datas and images.

Upvotes: 0

Views: 642

Answers (1)

Raymond Camden
Raymond Camden

Reputation: 10857

Why not use WebSQL? As a web standard, it is dead, but it works well on mobile and works great in PhoneGap/Cordova. As for images, I'd probably store them as binary though on the file system.

Upvotes: 1

Related Questions