Database Access Service

Ok guys, I used to ask how to create a way to run code always in my application. This is similar to what iMobeter says or something like this checks your hp, if it is less than max, it will add it every 5 minutes.

Some people told me to use a service that sounded good. The problem is that I need a service that always runs in the background. In addition, I could not create a service that can access the database. I cannot use the cursor there, since the method is not supported in it.

I would appreciate a good example or a better way to do this.

+1
source share
1 answer

The problem is that I need a service that always runs in the background.

It's impossible. Users can stop your service whenever they want, and Android will stop your service if it takes too long.

In addition, I could not create a service that can access the database. I cannot use the cursor there, since the method is not supported in it.

Yes Yes. Use SQLiteOpenHelper , just like with an activity, content provider, etc.

+3
source

Source: https://habr.com/ru/post/1396570/


All Articles