stelios
stelios

Reputation: 1027

Prefer Database or File for data in Android

I already have a database and when i write in it i also want to write only one value(store a counter)!because i think that searching for a value first and then search again for a value of counter will be slow i thought using a file to store the counter...but read write delete wouldn't be slow? So,which one is faster and safer(from point of less chances to break)?which method should i be using?

Upvotes: 0

Views: 414

Answers (2)

Hafiz
Hafiz

Reputation: 4267

As this is only one value and only one user will be using it at a time so I think file will be better because database is easy to search and insert by a query language while file system is simple and fast but only less use because it become difficult to handle the things that we handle with db.

In your case it is a simple counter so it is better to use a single file.

Upvotes: 0

Ganapathy C
Ganapathy C

Reputation: 5999

Use SharedPreferences for storing a single value it will be very efficient.

Upvotes: 8

Related Questions