Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Both the methods editSave() and populateData() require access to a database to function. They both should be modified to use AsyncTask in order to reduce the footprint that your code has on the 'main thread'.

I presume the database is local to the device because otherwise you would be getting the notorious NetworkOnMainThreadExceptionNetworkOnMainThreadException... but regardless, for the same reason that NetworkOnMainThread has been designated as a critical problem, database access should be treated the same way. Any time you have IO or other non-CPU bound activities, you really should be using the AsyncTask, and there's a good example on StackOverflow tooa good example on StackOverflow too.

Both the methods editSave() and populateData() require access to a database to function. They both should be modified to use AsyncTask in order to reduce the footprint that your code has on the 'main thread'.

I presume the database is local to the device because otherwise you would be getting the notorious NetworkOnMainThreadException... but regardless, for the same reason that NetworkOnMainThread has been designated as a critical problem, database access should be treated the same way. Any time you have IO or other non-CPU bound activities, you really should be using the AsyncTask, and there's a good example on StackOverflow too.

Both the methods editSave() and populateData() require access to a database to function. They both should be modified to use AsyncTask in order to reduce the footprint that your code has on the 'main thread'.

I presume the database is local to the device because otherwise you would be getting the notorious NetworkOnMainThreadException... but regardless, for the same reason that NetworkOnMainThread has been designated as a critical problem, database access should be treated the same way. Any time you have IO or other non-CPU bound activities, you really should be using the AsyncTask, and there's a good example on StackOverflow too.

Source Link
rolfl
  • 97.5k
  • 17
  • 218
  • 418

Both the methods editSave() and populateData() require access to a database to function. They both should be modified to use AsyncTask in order to reduce the footprint that your code has on the 'main thread'.

I presume the database is local to the device because otherwise you would be getting the notorious NetworkOnMainThreadException... but regardless, for the same reason that NetworkOnMainThread has been designated as a critical problem, database access should be treated the same way. Any time you have IO or other non-CPU bound activities, you really should be using the AsyncTask, and there's a good example on StackOverflow too.