简体   繁体   中英

Android Development SQLite vs. Hashtable

So I'm following a tutorial on how to create a simple Android app that stores a bunch of random quotes. I've noticed that they used a SQLite database and many other Android tutorials uses SQLite to store things. I'm not very used to SQLite. Can I achieve the same result just by storing the quotes in a hashtable?

What are the differences between a SQLite database and a hashtable in terms of performance?

What are the differences between a SQLite database and a hashtable in terms of performance?

An (in-memory) hash table is (you probably should use HashMap ) is going to be faster. However, it does not address the problem of making your quotes "persist" when your app has shut down.

SQLite is a database, and the main point of a database is that the data persists.

(There are a whole bunch of other benefits in using a database of some kind. One that is potentially relevant to you is that you can store more stuff in a typical database than you can hold in memory. The database stores stuff on your device's hard drive / SSD / whatever which has far more capacity than main memory.)

http://www.brighthub.com/mobile/google-android/articles/25023.aspx

I suggest SQLite because u can access the database very easily and it is easy to understand and view the database tables also very easy through DDMS plugin for eclipse The above link helps you in DDMS

It's up to your intention. If you want to store data such as app preference, user score.. use SQLite. These data will be available for the next launch of application. Hashtable is in memory, of course it is faster than SQLite, all information stored in Hashtable will be lost when the app is deactived or terminated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM