Android上SQLite的最佳做法是什么? - What are the best practices for SQLite on Android?

07/08 19:24
阅读数 13

问题:

What would be considered the best practices when executing queries on an SQLite database within an Android app? 在Android应用程序中对SQLite数据库执行查询时,最佳做法是什么?

Is it safe to run inserts, deletes and select queries from an AsyncTask's doInBackground? 从AsyncTask的doInBackground运行插入,删除和选择查询是否安全? Or should I use the UI Thread? 或者我应该使用UI线程? I suppose that database queries can be "heavy" and should not use the UI thread as it can lock up the app - resulting in an Application Not Responding (ANR). 我认为数据库查询可能“很重”,不应该使用UI线程,因为它可以锁定应用程序 - 导致应用程序无响应 (ANR)。

If I have several AsyncTasks, should they share a connection or should they open a connection each? 如果我有几个AsyncTasks,他们应该共享一个连接还是应该分别打开一个连接?

Are there any best practices for these scenarios? 这些方案是否有最佳实践?


解决方案:

参考一: https://stackoom.com/question/ASd1/Android上SQLite的最佳做法是什么
参考二: https://oldbug.net/q/ASd1/What-are-the-best-practices-for-SQLite-on-Android
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部