Good morning!
I'm currently creating an Android app that have a list of texts and show one randomly. I would like to update the list from a server and I don't know what is the best way to do that.
I plan to use an sqlite database in order to download only the new datas.
Since each text is associated with an image, I consider using Blob in my database, but I don't know if using blob is really a good practce.
Should I store the path to the images instead?
https://www.digitalocean.com/community/tutorials/sqlite-vs-mysql-vs-postgresql-a-comparison-of-relational-database-management-systems
http://database-management-systems.findthebest.com/compare/30-53/MySQL-vs-SQLite
these two websites can give u a better idea which one to opt. !
Every aspect has been defined in these two sites. Hope i helped u there.
My suggestion:
Making use of JSON support in PostgreSQL is a benefit over other RDBM's
as it's fast.
Related
I have been asked to create a tiny android app.
In everyday work i code for .NET and I have no experience connected with Android, but as it is a really small app I guess it's going to be a good experience rather than something hard.
The core of the app would be a small database (probably XML, unless somebody suggest better solution) that would contain categories, names of the institutions assigned with each category and logo (not very high resolution I guess a single file would be <100kB) of the institution.
The database also would not be very big - I expect not more than 1000 records in total. The DB has to be totally offline and local, it cannot require Internet access when operating.
The model I assume would be to ship new version of the application when the database changes (which is not going to be very frequent).
What is the best way to deal with these requirements?
My first idea was to create an XML file that would contain the records and link to the image. The XML and all the images linked to it would be stored in single file (preferably zip) that would be stored in app resources. This is very good as it is going to be very easy to update the database.
The second idea that somebody suggested me would be to use SQLite and store images in BLOB. In general I have read that it isn't a good idea to store images in database directly, and I am afraid if it's going to be possible to meet all requirements mentioned above.
Mostly I have no idea how to update the database easily and attach it to new version of application.
Any suggestions?
I would be grateful for any response.
I wouldn't go about using XML to save your data and by no means zip anything.
I think your way of thinking is ok, but you're making things really complicated for yourself.
Seeing as you're used to .NET I suppose you're also pretty confident with SQL, so I'd suggest you have a look at how to use the built-in SQLite database in Android.
If you would go the XML route you'd have to serialize and de-serialize the XML file over and over again and then parse the XML. Ok you don't have a lot of data, but searching inside an XML file with at least 1000 nodes would be slow in comparison to the performance of a database.
Also upgrading an existing SQLite database is not that hard - Android has methods for that (onUpgrade coming from the SQLiteOpenHelper).
As to saving images I'm assuming that you won't fetch new pictures from the Internet, so it would be best just to store them in the drawable folder of your app (be mindful of different screensizes) and then reading them into an ImageView when needed. To figure out what image should go for what institution I would store either the image name of each image in the SQLite database or store the resource id for each image in the database - for instance R.drawable.myawesomepictureformyinstitution.
I know my answer is somewhat "superficial", but your question is also somewhat "broad" and hard to answer without me actually writing most of the code, and that's not my intention ;-)
Hope this helps - let me know if anything is unclear.
I have some really huge data that is required for my android app. I've put it into a sqlite db now. Roughly it is 39k rows and 5 columns. I want this data to be available for my app.
I'm kind of confused as to how I ship my app with it. i can ship the db file with it like discussed in this thread. or I can somehow create XML out of that data and ship it along. But the XML would be really huge. So what is the right way of doing it?
I do not want to download it after user installs the app. That'd be my last option if there are no better clean ways of doing it.
This should help you.
http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/
Basically just ship the database with your apk file.
I think shipping your DB could make some problems with compatibility.
Maybe it will be better to use GZIP'ed SQL code bundled to your .APK?
Or instead of XML for intermediate representation you can use google protobuf, which is most effective data representation format(Also, if you have a lot of strings, you can use it in combination with GZIP).
Check the example here to achieve this functionality.
I'm making a game to run on android. So I want to store player names and the winner, which I will also list up in a view. What is the best way to do this, use a database or write to a file (if so, what type, xml?). I have to be able to add data after every completed game, and the size won't be so large. What would be the best solution?
IMO, using a SQLite database would be the most straightforward. You don't have to worry about the xml parsing that goes along with an xml file. Additionally, the data your storing seems to have a natural relationship that would be conducive to a SQLite schema. For more information about how to use SQLite in Android, see the data storage documentation here.
SQLite is great if you have database concerns and want that sort of data lookup.
However, if you really want to do it Simply with XML then you can in Android.
Hello this is probably a typical question but i cant seem to find a clear answer?
I have a backend application that will serve data in json form.
The data will be in form [code] [name].
The data sets might vary from 100-2000 rows.
What would be best...
Store directly these json responses as files and then parse them if they exist?
Or store them in the android database?
In each case the data does not change that often maybe 1 per week.
Which way would be the faster and which more efficient?
Thanks
I think database is much more preferable way here. Text rows even in quantities like 2000 on smart phones better not to be handled in text I think.
I'd go for the Sqlite db too, I'm quite sure that it's much faster than using basic file i/o.
I am making an android app which is going to need a lot of pictures. But I can't have them all in the app since it would be like 10 gigabytes or something. I have read some other questions where they say its smarter to store the url to the pictures in a database. My question is, should the image url be stored in the application itself or in the database?
The DB is a part of the application itself. Is it not? If you are talking about hard-coding , keeping them in DB is better keeping extensibility in mind but would involve extra call to DB.
Hard-coding them would be better performing (How much, you need to test that).
Alternatively you can make use of build tools by storing the urls in a configuration and replacing them at the time of build. While this solves above two problems, It adds complexity to the code.
So everything has its gives and takes, you need to decide what to chose on your requirements and priorities.
If you store the URLs in a database, you are able to manage your images easier, as you don't have to hardcode everything.
store URL in a DB will more preferable. And you can load the images using picasso library would better easier and comfortable way.
Its always better to store image url's in a database, whether that database resides on your phone, or on the server and you fetch it from there using rest services is upto you.
You can use multiple libraries for image lazy loading in your app.
[1]: https://github.com/nostra13/Android-Universal-Image-Loader "Universal Image Loader" is by far a very good third party library.
You can also add your own lazy loading algorithms by creating a basic Thread Pool.