dear programmers!
My question is about inserting data in SQLite, in such a way that there are four five items of spinner(dropdown list)
for any item of spinner there is a table in database, the tables are:
1- lcd
2- crt
3- dish => short form of dish antenna
4- antenna
5- cd_dvd_player
I have determined the algorithm in such a way when i choose any item of spinner, the data of the item should be inserted in its related table
like; above five tables, but toast message shows wrong data inserted while in fact is not inserted. The codes are as following:
if you answer my question, you would have helped a lot thanks a lotenter image description here
In short you are likely going to encounter numerous issues if you try to store large images in the Database.
The recommended way is to store the images as files and store the paths or part of the paths in the Database, using the stored path to access the images when required.
It very much appears that the screen shot is related to exceeding memory limitations.
Related
I have made a table with user info already stored in it. When the user registers with the id, all the details like username, course are retrieved from the table if the id matches. Now I want to add profile pictures in my user info table. Almost all tutorials on the internet are about saving a photo from your phone into that database and retrieving it. But i don't want that. I would like to add different image into the table for each user, i.e. it should be specific to the user. Now I know a BLOB datatype is used and the images should be converted to bytes. But I don't know where I should store the images, whether in my phone or in my res folder. Or maybe store it on the internet. I am confused.
I should mention that this isn't an ideal application, its just a model.
One of the most important factors to consider is the size of the images. If the size is likely to be in excess of say 200k then there is an increasing risk of there being issues not with storing the image in the database but retrieving the image.
Without writing your own alternative of CursorWindow then a CursorWindow (a buffer to hold a sub-group of the rows in a Cursor) is limited to 2M in size (in later versions at some it I believe it was 1M). If a picture is approaching 2MB there is no way that the picture can be retrieved (even without considering space for other columns).
As such, the generally recommended approach is to not store images but store a means of retrieving the image from a file store elsewhere (you've mentioned the res folder, which could be fine but you may need to consider the size of the APK), you could then store the file path in the database.
There's a more comprehensive answer that covers the above including storing small images in the DB and larger images elsewhere (assets folder) here
For anyone who has the same question like me, I found this tutorial to be the most easiest way to store images and retrieve it. It uses an external sqlite database to store images and info, and access it in the java page to display which i found quite easy.
I really need to create a small DB for doing only SELECT querys in my app. Because of that I would like to know:
Does android provide something for design and fill a DB? I mean no programming. Something like phpmyadmin so I could fill it and make a relation between 2 tables before running the app in an emulator or a phone.
If I create a DB, will it be visible from some file in the user mobile phone? Because I read in android manual that it was invisible but in some places I read that it's saved in the mobile... I would prefer that this DB would be like a resource like it can be a layer or a string.
If I really need to create a DB each time the app is displayed for present the same information always, could I just "upload a sample" of that database in one line of code or so?
I need this for display a big list of items (maybe 2000 items) in different languages. I could do that just creating an array string resource but I need to order the list in a different way depending on the location of the user. At the end I need to retrieve an "ID" of the items selected but because it's impossible to do a 2D array string as a resource then I can't assign a number to the items so I can only know their positions in the list. The problem is that if I alter the items I will have a mismatch of positions numbers as ID.
This array is for an autofill text. I know I can put a comma after each item with the number and before adding this array to the autofill do a split and select the first column for the autofill and the second for compare position to real ID but I thought it would have a better performance to have all in a DB. Am I wrong?
1. Does android provide something for design and fill a DB? I mean no
programming. Something like phpmyadmin so I could fill it and make a
relation between 2 tables before running the app in an emulator or a
phone.
You can use Sqlite Browser to create a database
2. If I create a DB, will it be visible from some file in the user
mobile phone? Because I read in android manual that it was invisible
but in some places I read that it's saved in the mobile... I would
prefer that this DB would be like a resource like it can be a layer
or a string.
It depends on where you create. Usually if you open a database it will be created in /data/data/[yourpackagename]/databases . This folder is incaccessible in normal cases, but if you have a rooted phone you can access this folder. Also while creating you could change the path to sdcard which is accessible everytime
3. If I really need to create a DB each time the app is
displayed for present the same information always, could I just "upload a
sample" of that database in one line of code or so?
You could store the db in assets folder of your app and open it.
Edit:
If it is just a 2D array i think its better to save as a csv and extract. You could put it in assets or raw folder.
I am developing a glossary of terms in physics. In this glossary app, user can search the definition alphabetically as well as by category . Shall i store data in one table or create different table for different categories? which will be better. I want to develop something like this app https://market.android.com/details?id=com.beiks.bd_1119_NurserySongs_FULL but with images to explain it better. Shall i store the images also in database? Is there any way to use pdf files to display? Sample app with code will really be helpful. thanks in adv.
Shall i store data in one table or create different table for different categories?
I would suggest spending some time creating a normalized database structure, instead of splitting it into separate tables. For example, if you think you might assign one entry to multiple categories, that would call for a very different table schema (categories table, definitions table, and a definition_categories linking table that references the first two). If you don't need that, then having a single definitions table with a category column would be sufficient.
Shall i store the images also in database?
If you'll be shipping the application with the images included, then do not store them in the database -- the reason is because then you'll be using up twice the space for your images (once in the application resources, and once in the database).
If you'll be downloading the images from the Internet, it really comes down to personal preference.. The easy way would be to just download the images and store in your data directory, or on the SD card ("external storage").
Is there any way to use pdf files to display?
That depends on the device, and if it has a PDF reader installed. You can test for the existence of a PDF-capable application on the device using techniques described in this question.
I have a database with 4 tables. Each table has 1 column. 3 of the tables will typically hold only around 8-12 values, the other maybe 100+. The values are basic, color, city, etc. The user clicks a button, up pops a list with values they can select, delete or add.
It seems like a lot to have a table for ~8 values. I was wondering if there was a better way to store this data given that values need to be able to be added, deleted and the number will be dynamic.
I'm not trying to turn you off of using sqlite, but just to put down some other options.
They are, direct from the Data Storage Developer doc:
Shared Preferences
Internal Storage
External Storage
Network Server
I would recommend either Shared Preferences or Internal Storage for such a small amount of values. Performance wise, my understanding is you will get better performance using one of these two but I would get confirmation, I'm just repeating what I've heard at SO before. For such a small amount of values, I'm not certain that the difference is even measurable or will have any effect on your app.
In my android application, i have a genre list where, according to the selections made the thumbnails are uploaded to the selected one. I do the uploading of thumbnails by parsing my xml file. Even at the second time of selecting a genre from the list, loading time is same.
If the thumbnails are stored or cached , can the time for loading be reduced?
Which is best- storing in hard disk or creating a database?
Thanks in Advance,
Niki
This totally depends on the purpose: if you actually need a database - meaning that you need 1 or more tables with columns filled with various data. Or otherwise is you have a simple list with items it would be more efficient to keep them on hard disk.