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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:54:44+00:00 2026-06-09T11:54:44+00:00

With API16 the new WAL (Write Ahead Logging) was introduced in Androids SQLiteDatabase class.

  • 0

With API16 the new WAL (Write Ahead Logging) was introduced in Androids SQLiteDatabase class. I would like to test if WAL is enabled for a SQLite database. The app runs on older Android releases too, so I need a wrapper class for these new functions in SQLiteDatabase. The functions are:

  • public boolean isWriteAheadLoggingEnabled()
  • public boolean enableWriteAheadLogging()
  • public void disableWriteAheadLogging ()

In the Android Developer Blog I did find an article for a wrapper class that wraps new classes. What I didn’t find is a wrapper for new methods in an already existing class. How should I do that?

  • 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-09T11:54:45+00:00Added an answer on June 9, 2026 at 11:54 am

    The constructor for SQLiteDatabase is private so your’re not going to be able to extend it and add “wrappers” to the class itself. You can however just write a “helper” wrapper like so:

    public class WALWrapper {
        private boolean mAvailable;
        private Method mIsWriteAheadLoggingEnabled;
        private Method mEnableWriteAheadLogging;
        private Method mDisableWriteAheadLogging;
        private final SQLiteDatabase mDb;
    
        public WALWrapper(SQLiteDatabase db) {
            mDb = db;
            mAvailable = false;
            try {
                mIsWriteAheadLoggingEnabled =
                        SQLiteDatabase.class.getMethod("isWriteAheadLoggingEnabled");
                mEnableWriteAheadLogging =
                        SQLiteDatabase.class.getMethod("enableWriteAheadLogging");
                mDisableWriteAheadLogging =
                        SQLiteDatabase.class.getMethod("disableWriteAheadLogging");
                mAvailable = true;
            } catch (NoSuchMethodException e) {
            }
        }
    
        /**
         * Returns <code>true</code> if the {@link #isWriteAheadLoggingEnabled()},
         * {@link #enableWriteAheadLogging()} and {@link #disableWriteAheadLogging()}
         * are available.
         * @return <code>true</code> if the WALWrapper is functional, <code>false</code>
         *  otherwise.
         */
        public boolean isWALAvailable() {
            return mAvailable;
        }
    
        public boolean isWriteAheadLoggingEnabled() {
            boolean result = false;
            if (mIsWriteAheadLoggingEnabled != null) {
                try {
                    result = (Boolean) mIsWriteAheadLoggingEnabled.invoke(mDb);
                } catch (IllegalArgumentException e) {
                } catch (IllegalAccessException e) {
                } catch (InvocationTargetException e) {
                }
            }
            return result;
        }
    
        public boolean enableWriteAheadLogging() {
            boolean result = false;
            if (mEnableWriteAheadLogging != null) {
                try {
                    result = (Boolean) mEnableWriteAheadLogging.invoke(mDb);
                } catch (IllegalArgumentException e) {
                } catch (IllegalAccessException e) {
                } catch (InvocationTargetException e) {
                }
            }
            return result;
        }
    
        public void disableWriteAheadLogging() {
            if (mDisableWriteAheadLogging != null) {
                try {
                    mDisableWriteAheadLogging.invoke(mDb);
                } catch (IllegalArgumentException e) {
                } catch (IllegalAccessException e) {
                } catch (InvocationTargetException e) {
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a RESTful API that we are doing in MVC3. We would like
new to Android. Checked the FAQs on the SDK site but didn't find anything
I am learning how to develop Android apps, using Eclipse. New to all of
I've looked at several other questions related, one answer even seemed like it solved
I am trying to test Python and Paypal integration. Here is my call to
I changed my Manifest to target API 16 because of a thing with ActionBarSherlock,
I installed the latest versions of SDK (API 16) and got the latest ADT.
The android sdk won't allow me to install api8 and api10 because there isn't
I currently have a tomcat servlet 1 running under the ROOT: api1.myhost.com:8080/ I'm using
Made an app targeting API8 and it's running fine on all emulator images all

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.