AJDM Jakiur Rahmanl
AJDM Jakiur Rahmanl

Reputation: 1

How can I save a file in internal storage from cordova app?

I have just started learning cordova. I want to know how to save something in Internal Storage. Which plugin and code should I use? Please help me. And if you have a demo project, please give it?

Upvotes: -2

Views: 1578

Answers (2)

eb1
eb1

Reputation: 2947

Not sure what's meant by internal storage -- I'm guessing something permanently on the device?

Cordova is not very prescriptive in where you should store your data, and that's kind of on purpose (if you listen to some of the videos, its original goal was to not be needed, once web apps became functional enough). That said, there's an article on the Cordova site that describes pros and cons of the various places you can store things with Cordova / javascript / plugins: https://cordova.apache.org/docs/en/10.x/cordova/storage/storage.html

On my app (https://github.com/adapt-it/adapt-it-mobile if you're interested in poking around), I use a combination of places to store things:

  • LocalStorage for user preferences; small bits of data that are less of a big deal if they're removed (iOS stores LocalStorage items in an area that could potentially be cleaned out)
  • SQLite (database) storage for the real stuff.
  • File export is done using cordova-plugin-file, as Akshaya mentions. I then use the social sharing plugin to present export options to the user (email, text messaging, etc.)

Upvotes: 0

Akshaya Jeevan
Akshaya Jeevan

Reputation: 634

You need to use cordova-file-plugin. This plugin can be used to access, read and write file. Check here - https://cordova.apache.org/docs/en/10.x/reference/cordova-plugin-file/index.html

You can also find sample examples for Create Files and Directories, Write, Read, and Append files

Upvotes: 0

Related Questions