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.
Related
I am developing an app for Android which will have many sentences organized with categories. Besides, this app must upgrade the sentences with a mysql database.
My question is: How can I save many sentences efficiently?
I have thought creating a sqlite database in my pc and add it to the app project. Is that possible?
Maybe, could I do another thing?
Like you said; create your database using sqlite on desktop and then include it in your application in the \assets folder. Use it normally in your application.
Remember to always us _id as the primary key in your tables.
For more details check this blog post
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 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.
Hi I am fairly new to Android development and am hoping someone can help me out with this.
Basically, the app I am designing needs to contain a large list of makes, models, and years for various cars. The user can then select the make/model/year they want and add this car to their personal list of favorites. What I have tried so far is to make a database with two tables: one listing every car, and one listing the cars the user has chosen as favorites. When a user selects a car from the table listing every car, ideally that data would just be copied to the second table.
This has been fairly difficult for me at my novice level and I am having some problems getting it to work at all. So i guess my question is: is there a simpler way I should do this (with multiple arrays or something)? Or should I man up and just keep going at it until it works?
I would stick with the database - it will serve you well for more advanced android development, and many other applications. Sounds like you need to get a book on SQL or fundamental database concepts - if the database is as you've described it you can just use one table and update the "Favourite" flag whenever that changes.
Using alternative structures can have it's own learning curve and be at the cost of performance, particularly if you've got a large number of records. Is there anything specifically you're stuck on?
You have to make two tables CarlistTable & favouriteTable . Add a Column favorite to carlist & make each entry 0 to this column & while mark it as favourite do two things 1.Update the perticular entry as 1 & save that entry to Favourite Table. Thats all.
I would suggest you to stick with the database because having arrays and hardcoding it will make your program bigger and needs more memory (even in RAM) which is limited in cell phones.
To get you thing done, I would suggest you to use flags as the folks have said
plus,
to ease your programming, use a dbHelper and make a function for copying data from one table to another, I think that is fairly simple.
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.