I am developing a mobile app using xamarin forms. I have to store few paragraphs to display on multiple pages.
I was wondering which is a better option LocalDb or files.
Depends how many paragraphs and how much time you want to spend.
The easy way is to use files. You just hardcode them and you read and edit their contents (page1p1, page1p2.. etc).
Local database is the better way to go because you can easily expand the number of pages and paragraphs and you it's easier to keep track of them. BUT there is more code to write... so it's not worth it for a small number of pages
Local files is a good solution in this case. You have a simple data structure and there is no reason to use additional memory and recourses when using a database.
Related
I have too much of data to be stored and am looking for a proper way to store them.
I can use strings-arrays or text files. Either way, what I want to do can be accomplished but I am looking for a better way considering app speed and size.
I am thinking of using string-arrays ( a lot of).Will this be a good decision?
I want to make my app offline and that's the reason of not using Firebase.
Consider an example of all the trains and their route stations. So I need a perfect advice by which the thing I am looking for can easily be done.
Thank you very much for any help.
You can store your data into SQLITE.
SQLite provides an easy and efficient way to deal with data rather than do the data processing internally inside in-memory
variables.
I want to make my app offline - Data storing is very easy and efficient in SQLite. Sqlite offers OFFLINE Mode.
Considering app speed and size - No problem. Loading data from an SQLite database is faster than loading data out of individual files .
I am developing a notepad app which can store simple text files and checklists. Currently I maintain a separate file (say info.txt) that maintains information about whether a given file is a simple text file or a checklist and based on that I render my UI (for either listing all files or opening a file) to show that file in my app. However I am not very happy with this approach because is slow and does not appear to scale well.
Is there a better way to add "metadata" (e.g. if it is a simple text or cheklist, tags, etc) about a file in android?
Any help will be greatly appreciated
There are several ways of storing persistent data in Android.
The way you are currently doing it is through the device storage, and you are quite right it would probably not scale well in addition to being directly accessible to the user meaning they could edit or delete your metadata.
Using SharedPreferences would be one way of storing the metadata which has the advantage of being completely hidden from the user, as well as being relatively easy to set up. The main disadvantages I can see are that it may not scale well if a user has a large number of files, and it is much more difficult to retrieve files with certain criteria, a certain tag for instance, as you mention in the comments.
The best way to store data that will scale well, be persistent, and let you run queries on the data would be an on device SQLite database. SQLite will usually have more overhead in terms of setup time, but is far more robust and featured than any of the other options besides perhaps network based storage, which based on the information you have given is probably not something you are interested in. Based on your problem the SQLite database is probably the way to go and has the bonus of being expandable in case you ever decide to add more information, or even store the files in the SQLite database.
I am trying to build a application which will be a Ebook kind of (Lot of theory & diagrams) will be there.
Now what i want to know is that since there are many ways of storing the data which one will be the best
Storing in Database
XML
Or simple text files
I am very concerned about the security of the data as well. Since this will be a paid app, i want the data to be secured and also be fast and convenient.
Also, I thought of converting the doc files (Data) in to epub format & then use epub api's to access the data and show it on the android app screen, will this be a gud idea to go for? as compared to the above ways?
Which one will be more secure, fast, flexible & easy!
It depends on how you will access to this data. If you will store in xml you will must to read the whole file from the start to access to chapter (or load to memory, for example). It's not good idea if you will store big data.
Storing in SQL faster. You can gain access to any chapter. You don't need to read all data, like in xml.
Simple text file has the same problem like XML (xml is textfile).
The only one way to secure you data - encrypt it. If user will get root on their device, he will gain access to your files and databases. There is no meaning where you will store your data.
Depends on what is more important to you - speed or security.
Speed
Definitely SQLite, it isn't exactly the cleanest, but definitely the fastest way.
Security
Custom files which are encrypted - it will take a while to read the whole file and then decrypt it in order to display it, but you can be sure that the attacker will access the files encrypted and without the knowledge of the encryption - those data would be useless to him.
EPUB
If you're concerned about security then don't, unless you know how to apply DRM...and that is not a way to go honestly.
I think that the best way to store big amount of data is database. In Android it is sqlite database. I recommend you to put all your text data into sqlite database. You can structure it in easy and beautiful way. Then put your images into assets folder and store the pathes to the the images in database.
Advantages of database solution:
Always well structured data
Easy way to update data with version control system.
You can store and get fast accesses to really big amount of data.
You can use encryption to protect your data.
Disadvantages
It is more complicate to write good code for database solution then for XML or JSON one.
P.S If you will decide to use XML I recommend you to change it to JSON. It is faster and easier to use.
Which one will be more secure, fast, flexible & easy!
Secure: It mainly depends on encryption system.
Fast: SQLite, you can read some advantages of SQLite here Android Performance : Flat file vs SQLite
Flexible and easy: Storing the encrypted files in internal storage is a flexible and easy way. I think it is secure enough. Here you can get some android security tips about storing data http://developer.android.com/training/articles/security-tips.html#StoringData
for saving little data you can use xml for strings but you lose fast loading factor
sqlite is good for almost every purpose, but Security
I intend to make an app which is a sort of dictionnary for a slang/a dialect. There are not many words (less than 1000). To store the data, I have 2 solutions :
storing data in a clean sqlite database (which I use to do in my apps)
storing data in 26 xml files
according to you, which solution would be the most flexible and the most clean to use ?
Thank You
1.For Better performance you must use sqlite insted of xml.
2.xml is more complex and you have to parse data by reading a tag, so its decrease performance and increase complexity.
Using sqlite database has more flexibility over storing in xmls
you can manage the data easily. other operations like searching, adding more, or deleting and related operations will be easier
you wont need to handle the store operations manually. if you use xmls then you need to store those separately which will be more complex.
(to be hones i dont find any reason to use 26 xmls in your case)
If you're going to only read from your files/database, you can use xml files, especially if you're going to cache the data during the life of your application. This won't make a big performance hit with your number of records/words and will be easier to manage during development. Also, check if you can use smaller number of files to simplify development)
You can also use text files (csv) for read-only data: they are easier to manage and read in the code.
If you are going to update the data or create related data (e.g. favourite words), Sqlite database will be better as it offers more flexibility and performance.
I would like to build some simple application - for example Todo list - and I am thinking about the problem and its solving - how can I to store data in my own application on Android platform?
I should to use some text file, xml file or some database? What will be better for beginner on this field?
You'll have a VERY hard time getting anywhere with Android if you don't read through their website/dev resources. I would highly recommend visiting their site.
As far as data storage is concerned, that varies based on your need. Explained here
My suggestion is to use SQLite that comes with Android. http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html
In my opinion, a SQLite database seems most appropriate for this kind of application. There is lots of support for using the SQLite database in conjuction with ListViews (which I imagine you'd want to use in your to-do list app).
In case you haven't already checked it out, see the page on the developer site:
http://developer.android.com/guide/topics/data/data-storage.html#db
Theres a few ways you can store data. I've created a few applications thats store data using shared preferences
They're quite handy for storing strings, ints, bool values etc. However if you have a large scaled application, that requires better database management, I would look into sqlLite.
Android has supported classes and functions to help access/store the information.
Theres a good tutorial on the android site called notepad that takes you through how to use sqlite.
That should get you started :)
Look at this Thread klick
Edit: its cool for less data, if you want to store and browse lots of data, you should use as SQLite Database
Using a file, database or xml based depends entirely on what kind of application you are building. For eg: If you parse an XML feed and store the results back in an XML file - it totally defeats the storage purpose!
Databases are used to store structured and related content like - news feed results, email client data, etc.
Files are more used for storing raw / binary content like storing images, attachments, etc.
BTW, if you are a beginner - you should try all of them! :)
Hope this helps!