In my application, I'm retrieving content from t开发者_运维知识库he database very often. So I'm likely to access data from database when it is required. For example, even within an activity I'll open and close the database 3 to 4 times. Is this enough to cause performance to suffer?
This would really depend on the amount of data you are reading and how complicated the queries are. Personally I wouldn't worry about unless you can notice the performance issue, why fix a problem that doesn't exist. That said if you are noticing performance problems and think the database may be the cause you can try the following:
- Cache database reads so they only have to be done when something is updated.
- Wrap database writes in transactions so the disk writes are done all in one go.
- Only read the data you need. For instance if you have a list the displays 3 out of the 20 fields only read the 3 fields you need.
精彩评论