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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:00:00+00:00 2026-05-26T20:00:00+00:00

For my application, I have a custom implementation of SharedPreferences . In API level

  • 0

For my application, I have a custom implementation of SharedPreferences.

In API level 9, the apply method was added to the SharedPreferences.Editor interface.

However, Android 1.6 throws a VerifyError if I add that method to my implementation and try to use it.

What is the best way to make this work in a backwards compatible way?

Edit:

I should clarify my conundrum. Before I switched to targeting Gingerbread, my implementation of SharedPreferences.Editor did not include the apply method. Upon switching the target, it ceased to compile due to that method being missing from my implementation.

Adding an implementation of the method fixed the compile problem, but added a new problem: Android 1.6 will not even load the class, throwing a VerifyError. Even if I catch the error, my custom implementation will never load on 1.6.

So far, my best idea has been to make my own interfaces identical to SharedPreferences and SharedPreferences.Editor, and implement those instead. Of course, that’s going to require sweeping changes throughout my code, so I’m trying to avoid it if possible.

  • 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-26T20:00:01+00:00Added an answer on May 26, 2026 at 8:00 pm

    If you were willing to drop Android 1.x support, you could just put this in an if () test, akin to:

    if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.GINGERBREAD) {
        editor.apply();
    }
    else {
        editor.commit();
    }
    

    If you really need to support back to Android 1.6, though, you will need to isolate the new-API code in a class that only gets loaded on new-API devices, the so-called “conditional class loading” technique.

    Here is a sample project demonstrating using this technique for your very problem.

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

Sidebar

Related Questions

My current project is created for API Level 4 and I use custom implementation
In MVC3 application I have my custom implementation of IPrincipal. I want to register
In my application I have a custom model binder that I set to the
I'm working on a web application that will have a custom UI for the
I'm looking into some XSS prevention in my Java application. I currently have custom
I have a custom application that was built to send opt-in newsletters and marketing
I have a custom built application framework written in PHP which I have been
I have a custom routing application that takes information for a route from google
I have a custom class loader so that a desktop application can dynamically start
We have a custom written on-line job application... application. HR is requesting a skill

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.