I'm developing and an application that uses a sqlite database, and I'm having trouble to store images in database, I read a lot of examples, but not working here, can someone tell me the best way to store images in SQLite?
(and then I'll need to store movies as well..)
In the future I'll have to develop a backoffice so the company can add/change/delete items in the db.
Can you please help me?
Thanks!
I know that this does not exactly answer your question:
I'd not bother storing those huge blobs in sqlite, but rather store them on file system and only store the file names/paths in sqlite.
This will save you from the hassle of putting the stuff in the DB and manipulation of files (create, delete, list) is relatively easy through java.io.File and FileInputStream etc.
See e.g. PicHelper as a class that deals with storing / loading data in/from files.
Related
I have started learning Android development and I have a very newbie question. I understand that Android can store data in SQLite for example, but what other approaches are there to the storage of data within your application?
Do Android apps ever have data 'embedded' within the application, in which case what sort of data structure or concept would this use?
I am thinking of a scenario where the data is static but is perhaps not a large enough dataset to warrant a database..e.g. an app with general knowledge questions and answers
Any guidance much appreciated
Rowan
Yes You are correct You can use SqLite Database for storage
other ways to store data is SharedPreferences
But in your case you wanrted to save questions and answers which is static one so you can create a text file and put that in your assets folder and you can read that file as any other text file in java
Refer this link how to read file from assets folder
1.Sqlite Database
2.Shared preferences
3.Internal memory
4.external memory i.e sd card
i would suggest you to go with Database. as it will let you store as much data as your app needed, There are some other option also present like
Sharedpreference i.e. cookies in general term. It let u store only few KB data and not good to store much data. When u retrieve data from cookies. All data will be store into ram and use app memory. that is use less when u do not need all data to retrieve and store into ram and then remove
Store into file and ship that file with your app. Yeah. this could be better idea again. you need to read it byte by byte. and hence reading to mid or last line will store all data into ram and hence will take memory.
Use Web Service to download data. It will let you store Large data and you have to download using Web APi. Hence it could be better idea. But this requires active Internet connection to play game to run app.
There must be some other option also present. You can search. surely you will find them :)
Overall Database it good solution for all app. As it will let you do search store delete and let you do other operation in less amount of memory. In Mobile Development Memory is very Important thing we have to take care of.
Let me know if you have other unclear thought.
item
You could also store info in a server.
Pros :
You can change the content without needing user-side update of the app.
Cons :
Your app (mostly the UI) would need to manage connection problems.
You may need to implement async tasks for querying data from server.
I want to perform a simple action, to upload user images from the app to online server to store them and to have them available for future uses.
For that purpose, I will use Volley library.
Basically I would convert the image into Base64 format, send it to server, and store it.
My question, however, is that I have read answers to other questions here at stackoverflow about BLOB for storing data into database. Could anyone explain if BLOB is needed in this case or if am I mixing concepts here?.
INFO: My initial idea is to store the images in another folder in the server, and maybe the name and the path to the images in the database...but not the image in the database.
Making your own external Folder for saving images would be better than saving the Images in the database , because when you save the images as BLOB in the database some of the problems you face in database transfer is that, the database becomes to huge to transfer , but when you create a folder aside and you just call the names of the images in the Database , that is much more better. and Volley is also good in this.
If you need like a code sample i can post it
Thanks .
I am making an app for android which uses quite a lot of images and videos so I decided a MySQL database would be the best idea for storing all the media. I have never done this before and when I looked around to try and find out how I could go about storing videos in a database, I was told that it is generally not a good idea to store whole videos in a database. Could someone please explain why this isn't a good idea, as I have looked around and can't find any decent info on the subject.
What I have done though is instead of storing the whole video as a blob, I instead stored a string of the url that links to the video. Is this how storing videos is usually done?
Look, even when most relational databases such as MySQL can habdle media content, they are designed to store text information (characters, numbers, etc).
If you use your database to store images and/or video, everytime you run a query to get the content, the database will be working so hard because you're storing/reading a huge amount of data and database motor will have to reconstruct all the content on every query, and also, you may have to do some tricks to read it as a stream. This will impact the performance of your system in a negative way.
Remember that you'll be using that content so often, which means database will be handling a heavy load.
I suggest you use the database to store the URL's of the contents and just use it to retrieve the url of the element you want to use.
I Agreed storing video is not a good idea in database coz time comes up that you gonna face a serious problem when it comes of fetching data if you already have a bunch of videos and images in your tables. Must better to make it a file system then store the path at your table.
Good luck!
I'm developing a social photo app that is like instagram and I need to improve the application performance, to do that I need to persist some data, like timeline feed, photos, messages, etc.
I'm already using Shared Preferences to save user informations.
I don't know which is the best way to persist the data, I'm between SQLite or Files, to save the json data or something else.
Which is faster and gives me less trouble?
If somebody could help me I would appreciate it.
take a look at this caching images will provide better solution.
http://developer.android.com/training/displaying-bitmaps/cache-bitmap.html
If you need different queries on this data, than i strongly recommend to use SQLite. Cause it's not possible to make select queries on files without storing it to memory.
Even if you use this object as is without any special queries, you can store json objects to base.
SQL:
1) Fast.
2) Possibility to make select queries with different WHERE condition.
3) Easy update.
4) etc
I do not see the advantages to store this data to files...
If you will store data in files, it will slow if there will be a lot of data. Even if you will use sax parser.
But, images you should store as files, and only update link on it in data base.
I am developing an Android application. This app deals with contact information (name, number, photo), which I need to store locally for later processing. This data also needs to be modified frequently.
What would be a good way to achieve this? I was thinking of "File input stream Internal file storage(achieved by serialized)" and SQLite, but am confused about both of them.
Can anyone tell me the difference between these two in terms of performance, speed, memory consumption etc.?
(Besides, what is SQLite3?)
(My personal opinion)
Database is slow compare to File but it help you in getting data in arranging formats and easily you can perform any aggregate function on it. I suggest you to use Database in your requirements. As you can store particular record in arranged format.
SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.
as your data is like contact information name, number, photo for any people so prefer SQlite it will be easy and effiecent to add update and delete
Consider the point native Contact also uses the SQlite for same type of data set