When to store data in database or file

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

When to store data in database or file

Postby Denvar » Wed Oct 15, 2008 8:45 pm

Is there a recommendation, or pros/cons to storing application data in the database as apposed to in a file on the phone.

The data that im looking to store is a list of sets of 3 items eg.
John - Red - 60
Peter - Blue - 71
Mike - Red - 24

Currently I just have this stored in a csv file.
Denvar
Freshman
Freshman
 
Posts: 4
Joined: Mon Oct 13, 2008 9:56 pm

Top

Postby MrSnowflake » Wed Oct 15, 2008 8:58 pm

The database will probably (my guess) use more memory, but for huge amounts of data it wil be a __LOT__ faster.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby Denvar » Wed Oct 15, 2008 9:03 pm

well the file im currently using contains around 870 lines of data like the above example
Denvar
Freshman
Freshman
 
Posts: 4
Joined: Mon Oct 13, 2008 9:56 pm

Postby MrSnowflake » Wed Oct 15, 2008 9:07 pm

How are you using the file? reading it in to the memory and search from there? Then I'd definately use a database. If you just log stuff to the file, then the file is the best option.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby Denvar » Wed Oct 15, 2008 9:14 pm

Yeah the app reads a particular entry in the file when the user performs a certain action.

So yeah im guessing DB is the way to go, saves searching through the file each time.

Thanks for the info :)
Denvar
Freshman
Freshman
 
Posts: 4
Joined: Mon Oct 13, 2008 9:56 pm

Postby MrSnowflake » Wed Oct 15, 2008 9:17 pm

Np
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Top

data base connectivity

Postby anjanav » Fri Oct 31, 2008 8:40 am

Hi every body
can any one plz tell me that how to fetch an external DB{created in SQLite or SQL SERVER} stored in local hard drive in to android emulator.
all the examples i have searched in the net has shown that how to connect to a data base created within the emulator.
it will be good if u can provide me the sollution by some sample application

Thanks in advance
Anjanav Das
anjanav
Freshman
Freshman
 
Posts: 2
Joined: Fri Oct 31, 2008 8:27 am

Postby MrSnowflake » Fri Oct 31, 2008 11:23 am

You would need a database server on the computer and a database client on Android. Look for MySQL and MySQL for java or something like that.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby anjanav » Fri Oct 31, 2008 11:43 am

Thanks for ur responce,
but i need some suggestion regarding the installation of sqlite on android to connect my existing sql data base.

NOTE:
"MY MOTTO IS TO FETCH MY ERP DATA IN ANDROID THROUGH ECLIPSE WHICH IS IN SQL SERVER 2005"
anjanav
Freshman
Freshman
 
Posts: 2
Joined: Fri Oct 31, 2008 8:27 am

Postby MrSnowflake » Fri Oct 31, 2008 6:25 pm

You can't use SQLite and a database server, you need a real networked sql lib. I guess there's a sql server java lib.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby Ramblurr » Fri Nov 07, 2008 6:59 pm

I have another use case scenario that falls under this question of "Database or File"

I need to store a list of items:
Code: Select all
Item1
Item2
Item3
Item4
..
ItemN


The list will never be very big (never > 50 items), and when I read it I'll either be reading in the very first line, or the entire list. Instinctively, it seems a file would be better for this, because a dbase would have quite a bit more overhead than I need. Does that sound true?
User avatar
Ramblurr
Freshman
Freshman
 
Posts: 4
Joined: Sat Oct 25, 2008 5:40 am

Re: data base connectivity

Postby Sparkletron » Sun Nov 09, 2008 12:01 am

anjanav wrote:Hi every body
can any one plz tell me that how to fetch an external DB{created in SQLite or SQL SERVER} stored in local hard drive in to android emulator.


This is indeed possible. However, you have to initially create the database using Android because Android will add a special metadata table that must be present in the DB. Or you have to add this table and metadata to your existing DB (sorry, I don't have specifics on this).

After you create the DB file using Android, use DDMS to pull the file out and put it somewhere else. You can then add your own tables, etc. Finally, use DDMS to put the file back.

All of this can even be done programmatically within certain file size limits.
Sparkletron
Developer
Developer
 
Posts: 26
Joined: Tue Nov 04, 2008 6:17 am

Postby MrSnowflake » Sun Nov 09, 2008 11:50 am

Ramblurr wrote:I have another use case scenario that falls under this question of "Database or File"
...
In this case I would use a file.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 3 guests