Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9060807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:19:29+00:00 2026-06-16T15:19:29+00:00

After an update of the App I need to fill uniquely the databases with

  • 0

After an update of the App I need to fill uniquely the databases with additional data from the internet. For this purpose I’ve implemented a service called OnUpgradeService(). This service should be started in the OnUpgrade() method of the SQLiteOpenHelper.

I can see that startService is executed but onStartCommand() is not called.

public class MyContentProvider extends ContentProvider {
    ...
    private static class MyOpenHelper extends SQLiteOpenHelper {
        ...
        public MyOpenHelper(Context context, String name, CursorFactory factory, int version) {
            super(context, name, factory, version);
            this.context = context;
        }
        ...
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            if (oldVersion == 1) {
                db.execSQL(DATABASE_CREATE_THUMBNAIL);
                db.execSQL("alter table " + DATABASE_TABLE_FRIEND + " add column " + KEY_THUMBNAIL_URI + " text;");
                ...
                Intent intent = new Intent(context, OnUpgradeService.class);
                context.startService(intent);
            }
            else {
                db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE_FRIEND);
                onCreate(db);
            }
        }
        ...
        public class OnUpgradeService extends Service {
            ...
            @Override
            public int onStartCommand(Intent intent, int flags, int startId) {
                Thread t = new Thread(new Runnable() {
                    public void run() {
                        upgradeDatabase();
                        stopSelf();
                    }
                });
                t.start();
                return Service.START_REDELIVER_INTENT;
            }

The relevant entries in the manifest looks as follows:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" >
    ...
    <application>
        ...
        <service android:enabled="true" android:name=".OnUpgradeService" /> 
        ...
    </application>
    ...
</manifest>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T15:19:30+00:00Added an answer on June 16, 2026 at 3:19 pm

    The app does neither crash nor are there any hints in the LogCat why the Service is not started

    I find that somewhat difficult to believe — I am willing to bet that there are some warnings (not necessarily errors) related to this.

    Android components, like a Service, cannot be an ordinary inner class, as then Android has no way of creating an instance. Your OnUpgradeService would need to be a static inner class.

    Then, if you make that change, your manifest entry is wrong, as it claims that OnUpgradeService is not an inner class of anything.

    The simplest way to fix both problems is to move OnUpgradeService to be a regular top-level public Java class, in its own file.

    All that being said, I will be fairly surprised if you find that your given approach will work well over the long haul. Burying something like populating a database from the Internet the way you have seems like it will give you lots of problems. As it stands, it is relatively unpredictable when you will be asked to populate the database, as it will be whenever somebody tries performing some operation on this ContentProvider, and that may not be an appropriate moment. Also, there is the question of what the user will see immediately, while the data population has not occurred. I would strongly encourage you to think much more seriously about your data synchronization model, rather than considering it to be some side-effect of a whenever-it-happens database schema change.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to modify an existing Windows CE app which gets it data from
I have an app I need to update with new data for the DB.
After update our iphone app can not access the keychain. The distribution certificate has
I have a free App that I am about to update. After the update
After I updated from GAE-JAVA-SDK-1.5.5 to 1.6.0 and 1.6.1 my app stop functioning properly.
UPDATE: After searching a bit I don't seem to be alone about this problem:
I have an iOS app that uses sqlite3 databases extensively. I need to add
After update, when I try to start my ruby app, I have an error:
Am coming back to building a FB app after some time away from the
I need to count sequential timeout exceptions from SqlBulkCopy. To test this, I use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.