I want to write an android application that contains lots of data.
For example, I've about 30 categories, each category has about 50 items and each items consist of 10 text pages and 5-8 pictures.
I want my app to work offline and doesn't need internet connection.
What is the best and safest way to do it?
You should use sqlite database. Database is the best way to keep big amount of data structured.
You can put all your text data in tables. You can also put images to tables as blob or put images to assets folder and database will store path to image.
Just create sqlite database with all needed data on your PC and then attach it to your android app. You can easily find lots of information how to work with sqlite in android.
If You have every thing Hardcode . then you can put them all in assests folder in your project and then can read from code any file you want by different methods avaiable easily .
I would suggest you to use sqlite databse which is easy . You can store large texts and images as well .
Other option is to store all this data in xml and use it and images in drawable folder.
But managing data will be difficult so try using database .
Related
I have a list of words (112,000 in alphabetical order) with one word definitions. The definitions are sometimes more than one and are in the format:
word:definition1|definition2|...
The max number of definitions for a word is 8.
I need a method to store these in a file (or more is okay) so they can be accessed by an android app. Only one word will be accessed at a time. This list will never change.
Considering SQLite, how would I insert the large data into a database?
Considering RandomAccessFile, how would I create a index for these words?
Is there another way?
Thanks.
I would suggest you to go with SQLite as it would be easy to fetch data as and when required and it would be simply easy to get/date/update data from particular position too.
One more benefit is that you can prepare SQLite database by using GUI tool too.
Now follow below procedure to use Existing SQLite database, means that you will have database ready with words data:
Prepare SQLite database same as we do in .NET , here you can prepare it using one of the best tool SQLite Manager which you can download it as a tool/add-on inside Mozilla Firefox.
Once you are done with database, simple paste it inside assets folder.
Now write a code to copy database from assets folder into our app. There are plenty of examples available on web for the same.
Use a sqlite DB , storing 112,000 or more shouldn't be a problem at all for sqlite .
Your can use your db schema something like the following :
And there can be multiple entries of wordId -> meaningId , for each word .
for pre-storing data you could use a tutorial provided by me in my blog : Using Pre-populated sqlite database in android
I need some advice. I am doing a grocery list app on the android platform. I am planning to add product images and name to the listview. I am using MySQL and php(using XAMPP localhost) to display the data. So far i was successful with the text display using AndroidHive's connect tutorial.
My question is how should i store the images:
Upload the images to the database using datatype BLOPB
or
Transfer the image to the localhost(htdocs) folder then store directory path(using varchar datatype) [not sure if its possible but I have done something similar in asp.net]
I have seen some example here but not too sure which would be easier for me(beginner level). Thanks!!
Its better if you store images to localhost and use the associated localtion in db.
Because, converting image files and then storing it database would be difficult.
On the other half, it would affect your DB size a lot.
Storing data at localhost would be effective as the size of local disk is not a problem. Moreover, you will have access to image files directly.
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'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.
I apologize in advance if this question is too broad or too "it-depends."
Basically, I need to make a decision about how to store and access data in my app. The app works very much like flashcards; the "front" of the card presents the topic and the "back" presents the details/explanation. At first it seemed like a SQLite database would work best for this type of structure (and maybe it really is, I just don't know) because the data is static and this model works well with the rows and columns structure of a db. (btw, as of now, I'm using openCSV to parse the csv files containing my cards. Thought it was easier than SQLite...)
My issue (finally) is that I want to be able to display images for some of the data items. Some cards, for example, should display a corresponding image. Is this something that I can do with a SQLite db? Like, have one column store the path to an image....? Maybe what I'm asking is really basic, but I just haven't seen too many examples to really have a good sense of the design options out there.
I might also be confused about how I would dynamically change my views based on whether there is an image available. Maybe that's just an issue of dynamically creating an imageview whose source is the file that the db points to...
In summary, I'd really appreciate some guidance on how I can fetch and display text data along with images when they're available, whether it be in SQLite or some other way.
Thanks!
If all this data is being shipped with the app, I'd suggest just keeping everything stored as resources. You can have string arrays for the topics and details, and you can store images either as drawable resources or as assets. In the latter case, you could store the asset names as another string array resource. (In the former case, you'd have to build a map from each card to the resource identifier. This is, unfortunately, one area in which the Android resources architecture doesn't shine.)
If you want to use SQLite, it has BLOB fields in which you could store the images themselves, or int fields in which you could store image resource identifiers. Take a look at the searchable dictionary sample project for how to build an SQLite data base from resource data.
Sorry but this really is a 'it depends' kind of topic.
Unless you're storing a large number of rows of data (around the order of 10 000) then an XML file would be your best bet. In a Train Timetable app I recently wrote we went with a XML SAX parser loading a 14 000 record database to memory and it took no more than 2 seconds on an HTC Hero, so even for large databases its pretty fast.
The SQLite option is preferable only if you want to make use of relationships that come with a database structure. It is better at handling large numbers of rows but terrible at handling images.
Since you're flash cards are not relational I would recommend an xml file, using the xmlSax parser, and a folder of images within your assets folder. You could even run the images through pngCrunch to save some space.
XML is very flexible, below is an example of what your xml file could look like. Check out http://www.w3schools.com/schema/ for more information on writing an xml schema.
<?xml version="1.0" encoding="UTF-8"?>
<cards>
<card title="card 1" topic="atopic" image="image file name">
<front>Lots of text</front>
<back>Lots of text</back>
</card>
<card ..>
..
</card>
</cards>