Are you saying the data being returned should be faster, or the UI blocks until your data is returned? If you are saying the query should be faster, see all the above replies, Since your data has the possibility to grow and queries might really become slow, you need to make sure your UI does not halt until the data is returned. This class should be invoked in a new AsyncTask and the activity you are running your UI in should display some sort of wait graphic or progress bar. This will at least tell your user that you app is doing something. I hope I understood what you are asking. I think I'm understanding it the same way everyone else is, but you don't seem to be replying to the fact that your db calls should be made on a separate thread because there will always be potential for the query to be slow, even if you've got the fastest query possible.
I just wish SQLite would implement stored procedures... On Oct 12, 1:29 pm, John Goche <johngoch...@googlemail.com> wrote: > On Wed, Oct 12, 2011 at 5:38 PM, Christopher Van Kirk < > > christopher.vank...@gmail.com> wrote: > > You haven't provided enough information to help you. > > > The question you need to ask is why is it slow? Are you opening and closing > > the connection many time? Too many records? Complex joins? Inefficient > > query? Lack of indexing? Unintentionally cartesianing? > > I don't have a lot of data. Just the following class accessed from every > activity in my application and the storeAndRetrieve method called (which > calls insert and delete sql statements on a handful of tables each having > around just 60 rows each at the moment). > > class DB { > > private DB(Context ctx) { > > dbHelper = new DBHelper(ctx); > database = dbHelper.getWritableDatabase(); > > } > > public static DB db(Context ctx) { > if (db == null) > db = new DB(ctx); > return db; > } > > // store and retrieve data > > public Data storeAndRetrieve(Data data) { > > putData(data); > > Data retData = getData(); > > return retData; > > } > > // ... data getters and setters > > private static DB db = null; > private DBHelper dbHelper; > private SQLiteDatabase database; > > } > > Yes when I run sqlite3 from adb shell it is fast, but for some > reason when an activity is pushed and reads the data once > opened it takes more than half a second which really slows > down the user experience. > > Thanks for your help, > > John Goche -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en