DB for only do SELECT querys - android

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.

Related

replacing an existing sqlite database in an android application

i would like to replace an existing SQLite database in an existing Android application, by another one to use it for a different purpose.
For being clear:
I have the source code of an application who displays an encyclopedia in french (grouped by major themes(humans, animals..) every theme contains books (book one: human activities book 2...) every book contains chapters, and every chapter contains definitions..
My goal is to modify this application (just because i love its structure and general aspect!!) and use it to display an existing phone book grouped by regions, every region contains groups, every group contains clubs and every club have contacts (name, address and one phone number for every contact).
In the app. the database is putted in a raw file (res/raw/...) how can i know the structure of this database to make my phone book structure looks like it.
P.S: this isn't plajiurism... and also I would like to say sorry: I am a newbie in both of English language an Android programming :-)
how can i know the structure of this database to make my phone book
There are some Sqlite database editors available freely. Assuming that your database is a Sqlite one, if you open the database using one of those editors, you can see the database schema as well as contents of the database. You can also edit the contents if you wish.
See this question.
If you don't know how to use an existing database in your app, you can refer to this tutorial.

How to have lots of data in android app

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 .

How to store a large number of words (to be accessed by an android app)?

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

Should I use array or database

I am writing an app that contains a list of items with their information. When the users open the app, they would see the list, and when they select a particular item, they would get all the information about that item.
Right now my approach is I store the data in a multidimensional array in the java source file. When I push a new update, I might add new items in the java source file (so the array gets bigger). I wonder if this is the best approach. I tried looking up relevant information about array and database on the Internet, but I can't seem to find the information I need. Any advice for me?
Also, if in the future, I create a function for users to add their own items to the list, what's the impact?
If the user should be able to update it, if you should be able to update it dynamically (for instance update from internet), then the database is a must.
If that data is static and won't change unless you update the app, you can store it in the code or better, in a file (you can store in JSON format for ease of reading & parsing)
If use array, the newly added items by the user will be gone when the app restarts.
You can use a SQLite database stored directly on your phone (sd card for example).
An analysis of the storage options and what they're commonly used for can be found here. Personally I suggest SQLite database.
The database is good for permanent data, but realize it can create a bottleneck if writing to disk is not really necessary.
I am in the middle of refactoring an App to no longer use SQLite. I was inserting large amounts(10,000-100,000) of new rows at once, and it looked like it was going to take an hour based on my log feedback of the status. When I keep it in memory, it all loaded in about 5 seconds.

help needed for developing an android glossary application

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.

Categories

Resources