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 1063793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:50:11+00:00 2026-05-16T18:50:11+00:00

I am planning to write a free version and a full version of a

  • 0

I am planning to write a free version and a full version of a software. I want the information stored by the free version of the software to be accessible by the full version also (I don’t want to use Content Providers). And I also want to make sure this data is not lost when the software is updated. How do I achieve this?

  • 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-05-16T18:50:12+00:00Added an answer on May 16, 2026 at 6:50 pm

    You need to implement an intelligent way of onUpgrade for your sqlite helpers.

    You should always have the new table creation query at hand, and use that for upgrade and transfer any existing data. Note: that the onUpgrade methods runs once for your sqlite helper object and you need to handle all the tables in it.

    So what is recommended onUpgrade:

    • beginTransaction
    • run a table creation with if not exists (we are doing an upgrade, so the table might not exists yet, it will fail alter and drop)
    • put in a list the existing columns List<String> columns = DBUtils.GetColumns(db, TableName);
    • backup table (ALTER table " + TableName + " RENAME TO 'temp_" + TableName)
    • create new table (the newest table creation schema)
    • get the intersection with the new columns, this time columns taken from the upgraded table (columns.retainAll(DBUtils.GetColumns(db, TableName));)
    • restore data (String cols = StringUtils.join(columns, ",");
      db.execSQL(String.format(
      "INSERT INTO %s (%s) SELECT %s from temp_%s",
      TableName, cols, cols, TableName));
      )
    • remove backup table (DROP table 'temp_" + TableName)
    • setTransactionSuccessful

    (This doesn’t handle table downgrade, if you rename a column, you don’t get the existing data transfered as the column names do not match).

    .

    public static List<String> GetColumns(SQLiteDatabase db, String tableName) {
        List<String> ar = null;
        Cursor c = null;
        try {
            c = db.rawQuery("select * from " + tableName + " limit 1", null);
            if (c != null) {
                ar = new ArrayList<String>(Arrays.asList(c.getColumnNames()));
            }
        } catch (Exception e) {
            Log.v(tableName, e.getMessage(), e);
            e.printStackTrace();
        } finally {
            if (c != null)
                c.close();
        }
        return ar;
    }
    
    public static String join(List<String> list, String delim) {
        StringBuilder buf = new StringBuilder();
        int num = list.size();
        for (int i = 0; i < num; i++) {
            if (i != 0)
                buf.append(delim);
            buf.append((String) list.get(i));
        }
        return buf.toString();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm planning to write some software using SFTP with public/private key authentication to upload
I am planning to write a Role Base Access Control Mechanism. What I thought
I am planning to write a few git hooks as a project which logs
I'm planning to write an MVC blog engine, supporting multiple blogs. When creating a
I'm planning to write an application that would provide results in quick search box.
i am trying to write a blog application with CodeIgniter just for practice and
If you were starting a new web development project would you use ASP.Net MVC
This is a little related to my previous question Solaris: Mounting a file system
Are there any freeware/shareware examples of Silverlight desktop applications with a local SQL backend?
I am writing a component to parse data collected from various devices. Basic purpose

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.