Loading api/current.xml +40 −53 Original line number Diff line number Diff line Loading @@ -66018,7 +66018,7 @@ return="boolean" abstract="false" native="false" synchronized="true" synchronized="false" static="false" final="false" deprecated="not deprecated" Loading Loading @@ -66600,19 +66600,6 @@ <exception name="SQLException" type="android.database.SQLException"> </exception> </method> <method name="setConnectionPoolSize" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="size" type="int"> </parameter> </method> <method name="setLocale" return="void" abstract="false" Loading Loading @@ -247887,7 +247874,7 @@ deprecated="not deprecated" visibility="public" > <parameter name="fileName" type="java.lang.String"> <parameter name="path" type="java.lang.String"> </parameter> <exception name="FileNotFoundException" type="java.io.FileNotFoundException"> </exception> Loading Loading @@ -248010,7 +247997,7 @@ deprecated="not deprecated" visibility="public" > <parameter name="filename" type="java.lang.String"> <parameter name="path" type="java.lang.String"> </parameter> <exception name="FileNotFoundException" type="java.io.FileNotFoundException"> </exception> Loading @@ -248022,7 +248009,7 @@ deprecated="not deprecated" visibility="public" > <parameter name="filename" type="java.lang.String"> <parameter name="path" type="java.lang.String"> </parameter> <parameter name="append" type="boolean"> </parameter> Loading Loading @@ -248693,7 +248680,7 @@ deprecated="not deprecated" visibility="public" > <parameter name="b" type="byte[]"> <parameter name="buffer" type="byte[]"> </parameter> <parameter name="offset" type="int"> </parameter> Loading Loading @@ -283770,9 +283757,9 @@ > <parameter name="dst" type="byte[]"> </parameter> <parameter name="off" type="int"> <parameter name="dstOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="byteCount" type="int"> </parameter> </method> <method name="get" Loading Loading @@ -284016,9 +284003,9 @@ > <parameter name="src" type="byte[]"> </parameter> <parameter name="off" type="int"> <parameter name="srcOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="byteCount" type="int"> </parameter> </method> <method name="put" Loading Loading @@ -284255,7 +284242,7 @@ </parameter> <parameter name="start" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="byteCount" type="int"> </parameter> </method> </class> Loading Loading @@ -284488,9 +284475,9 @@ > <parameter name="dst" type="char[]"> </parameter> <parameter name="off" type="int"> <parameter name="dstOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="charCount" type="int"> </parameter> </method> <method name="get" Loading Loading @@ -284588,9 +284575,9 @@ > <parameter name="src" type="char[]"> </parameter> <parameter name="off" type="int"> <parameter name="srcOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="charCount" type="int"> </parameter> </method> <method name="put" Loading Loading @@ -284719,7 +284706,7 @@ </parameter> <parameter name="start" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="charCount" type="int"> </parameter> </method> <method name="wrap" Loading Loading @@ -284880,9 +284867,9 @@ > <parameter name="dst" type="double[]"> </parameter> <parameter name="off" type="int"> <parameter name="dstOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="doubleCount" type="int"> </parameter> </method> <method name="get" Loading Loading @@ -284969,9 +284956,9 @@ > <parameter name="src" type="double[]"> </parameter> <parameter name="off" type="int"> <parameter name="srcOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="doubleCount" type="int"> </parameter> </method> <method name="put" Loading Loading @@ -285040,7 +285027,7 @@ </parameter> <parameter name="start" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="doubleCount" type="int"> </parameter> </method> </class> Loading Loading @@ -285171,9 +285158,9 @@ > <parameter name="dst" type="float[]"> </parameter> <parameter name="off" type="int"> <parameter name="dstOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="floatCount" type="int"> </parameter> </method> <method name="get" Loading Loading @@ -285260,9 +285247,9 @@ > <parameter name="src" type="float[]"> </parameter> <parameter name="off" type="int"> <parameter name="srcOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="floatCount" type="int"> </parameter> </method> <method name="put" Loading Loading @@ -285331,7 +285318,7 @@ </parameter> <parameter name="start" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="floatCount" type="int"> </parameter> </method> </class> Loading Loading @@ -285462,9 +285449,9 @@ > <parameter name="dst" type="int[]"> </parameter> <parameter name="off" type="int"> <parameter name="dstOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="intCount" type="int"> </parameter> </method> <method name="get" Loading Loading @@ -285551,9 +285538,9 @@ > <parameter name="src" type="int[]"> </parameter> <parameter name="off" type="int"> <parameter name="srcOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="intCount" type="int"> </parameter> </method> <method name="put" Loading Loading @@ -285622,7 +285609,7 @@ </parameter> <parameter name="start" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="intCount" type="int"> </parameter> </method> </class> Loading Loading @@ -285770,9 +285757,9 @@ > <parameter name="dst" type="long[]"> </parameter> <parameter name="off" type="int"> <parameter name="dstOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="longCount" type="int"> </parameter> </method> <method name="get" Loading Loading @@ -285859,9 +285846,9 @@ > <parameter name="src" type="long[]"> </parameter> <parameter name="off" type="int"> <parameter name="srcOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="longCount" type="int"> </parameter> </method> <method name="put" Loading Loading @@ -285930,7 +285917,7 @@ </parameter> <parameter name="start" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="longCount" type="int"> </parameter> </method> </class> Loading Loading @@ -286120,9 +286107,9 @@ > <parameter name="dst" type="short[]"> </parameter> <parameter name="off" type="int"> <parameter name="dstOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="shortCount" type="int"> </parameter> </method> <method name="get" Loading Loading @@ -286209,9 +286196,9 @@ > <parameter name="src" type="short[]"> </parameter> <parameter name="off" type="int"> <parameter name="srcOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="shortCount" type="int"> </parameter> </method> <method name="put" Loading Loading @@ -286280,7 +286267,7 @@ </parameter> <parameter name="start" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="shortCount" type="int"> </parameter> </method> </class> core/java/android/database/sqlite/DatabaseConnectionPool.java +6 −8 Original line number Diff line number Diff line Loading @@ -246,17 +246,15 @@ import java.util.Random; } } /* package */ void setMaxPoolSize(int size) { synchronized(mParentDbObj) { /** only used for testing purposes. */ /* package */ synchronized void setMaxPoolSize(int size) { mMaxPoolSize = size; } } /* package */ int getMaxPoolSize() { synchronized(mParentDbObj) { /** only used for testing purposes. */ /* package */ synchronized int getMaxPoolSize() { return mMaxPoolSize; } } /** only used for testing purposes. */ /* package */ boolean isDatabaseObjFree(SQLiteDatabase db) { Loading core/java/android/database/sqlite/SQLiteDatabase.java +36 −64 Original line number Diff line number Diff line Loading @@ -1048,14 +1048,16 @@ public class SQLiteDatabase extends SQLiteClosable { * Close the database. */ public void close() { if (!isOpen()) { return; // already closed } if (Log.isLoggable(TAG, Log.DEBUG)) { Log.i(TAG, "closing db: " + mPath + " (connection # " + mConnectionNum); } lock(); try { // some other thread could have closed this database while I was waiting for lock. // check the database state if (!isOpen()) { return; } closeClosable(); // finalize ALL statements queued up so far closePendingStatements(); Loading Loading @@ -2102,7 +2104,7 @@ public class SQLiteDatabase extends SQLiteClosable { return; } if (!isCacheFullWarningLogged() && mCompiledQueries.size() == mMaxSqlCacheSize) { if (!mCacheFullWarning && mCompiledQueries.size() == mMaxSqlCacheSize) { /* * cache size of {@link #mMaxSqlCacheSize} is not enough for this app. * log a warning. Loading @@ -2110,7 +2112,7 @@ public class SQLiteDatabase extends SQLiteClosable { */ Log.w(TAG, "Reached MAX size for compiled-sql statement cache for database " + getPath() + ". Use setMaxSqlCacheSize() to increase cachesize. "); setCacheFullWarningLogged(); mCacheFullWarning = true; } /* add the given SQLiteCompiledSql compiledStatement to cache. * no need to worry about the cache size - because {@link #mCompiledQueries} Loading @@ -2134,7 +2136,8 @@ public class SQLiteDatabase extends SQLiteClosable { * From the compiledQueries cache, returns the compiled-statement-id for the given SQL. * Returns null, if not found in the cache. */ /* package */ synchronized SQLiteCompiledSql getCompiledStatementForSql(String sql) { /* package */ SQLiteCompiledSql getCompiledStatementForSql(String sql) { synchronized (mCompiledQueries) { SQLiteCompiledSql compiledStatement = mCompiledQueries.get(sql); if (compiledStatement == null) { mNumCacheMisses++; Loading @@ -2143,6 +2146,7 @@ public class SQLiteDatabase extends SQLiteClosable { mNumCacheHits++; return compiledStatement; } } /** * Sets the maximum size of the prepared-statement cache for this database. Loading @@ -2159,7 +2163,7 @@ public class SQLiteDatabase extends SQLiteClosable { * the value set with previous setMaxSqlCacheSize() call. */ public void setMaxSqlCacheSize(int cacheSize) { synchronized(this) { synchronized(mCompiledQueries) { if (cacheSize > MAX_SQL_CACHE_SIZE || cacheSize < 0) { throw new IllegalStateException("expected value between 0 and " + MAX_SQL_CACHE_SIZE); } else if (cacheSize < mMaxSqlCacheSize) { Loading @@ -2176,14 +2180,6 @@ public class SQLiteDatabase extends SQLiteClosable { } } private synchronized boolean isCacheFullWarningLogged() { return mCacheFullWarning; } private synchronized void setCacheFullWarningLogged() { mCacheFullWarning = true; } private synchronized int getCacheHitNum() { return mNumCacheHits; } Loading Loading @@ -2279,7 +2275,8 @@ public class SQLiteDatabase extends SQLiteClosable { * * @return true if write-ahead-logging is set. false otherwise */ public synchronized boolean enableWriteAheadLogging() { public boolean enableWriteAheadLogging() { synchronized(this) { if (mPath.equalsIgnoreCase(MEMORY_DB_PATH)) { Log.i(TAG, "can't enable WAL for memory databases."); return false; Loading @@ -2300,6 +2297,7 @@ public class SQLiteDatabase extends SQLiteClosable { } return true; } } /** * This method disables the features enabled by {@link #enableWriteAheadLogging()}. Loading Loading @@ -2338,32 +2336,6 @@ public class SQLiteDatabase extends SQLiteClosable { } } /** * Sets the database connection handle pool size to the given value. * Database connection handle pool is enabled when the app calls * {@link #enableWriteAheadLogging()}. * <p> * The default connection handle pool is set by the system by taking into account various * aspects of the device, such as memory, number of cores etc. It is recommended that * applications use the default pool size set by the system. * * @param size the value the connection handle pool size should be set to. */ public void setConnectionPoolSize(int size) { synchronized(this) { if (mConnectionPool == null) { throw new IllegalStateException("connection pool not enabled"); } int i = mConnectionPool.getMaxPoolSize(); if (size < i) { throw new IllegalArgumentException( "cannot set max pool size to a value less than the current max value(=" + i + ")"); } mConnectionPool.setMaxPoolSize(size); } } /* package */ SQLiteDatabase createPoolConnection(short connectionNum) { SQLiteDatabase db = openDatabase(mPath, mFactory, mFlags, mErrorHandler, connectionNum); db.mParentConnObj = this; Loading core/tests/coretests/src/android/database/sqlite/SQLiteDatabaseTest.java +1 −23 Original line number Diff line number Diff line Loading @@ -135,28 +135,6 @@ public class SQLiteDatabaseTest extends AndroidTestCase { c.close(); } @SmallTest public void testSetConnectionPoolSize() { mDatabase.enableWriteAheadLogging(); // can't set pool size to zero try { mDatabase.setConnectionPoolSize(0); fail("IllegalStateException expected"); } catch (IllegalArgumentException e) { assertTrue(e.getMessage().contains("less than the current max value")); } // set pool size to a valid value mDatabase.setConnectionPoolSize(10); assertEquals(10, mDatabase.mConnectionPool.getMaxPoolSize()); // can't set pool size to < the value above try { mDatabase.setConnectionPoolSize(1); fail("IllegalStateException expected"); } catch (IllegalArgumentException e) { assertTrue(e.getMessage().contains("less than the current max value")); } } /** * a transaction should be started before a standalone-update/insert/delete statement */ Loading Loading @@ -299,7 +277,7 @@ public class SQLiteDatabaseTest extends AndroidTestCase { if (useWal) { // set up connection pool mDatabase.enableWriteAheadLogging(); mDatabase.setConnectionPoolSize(i + 1); mDatabase.mConnectionPool.setMaxPoolSize(i + 1); } else { mDatabase.disableWriteAheadLogging(); } Loading Loading
api/current.xml +40 −53 Original line number Diff line number Diff line Loading @@ -66018,7 +66018,7 @@ return="boolean" abstract="false" native="false" synchronized="true" synchronized="false" static="false" final="false" deprecated="not deprecated" Loading Loading @@ -66600,19 +66600,6 @@ <exception name="SQLException" type="android.database.SQLException"> </exception> </method> <method name="setConnectionPoolSize" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="size" type="int"> </parameter> </method> <method name="setLocale" return="void" abstract="false" Loading Loading @@ -247887,7 +247874,7 @@ deprecated="not deprecated" visibility="public" > <parameter name="fileName" type="java.lang.String"> <parameter name="path" type="java.lang.String"> </parameter> <exception name="FileNotFoundException" type="java.io.FileNotFoundException"> </exception> Loading Loading @@ -248010,7 +247997,7 @@ deprecated="not deprecated" visibility="public" > <parameter name="filename" type="java.lang.String"> <parameter name="path" type="java.lang.String"> </parameter> <exception name="FileNotFoundException" type="java.io.FileNotFoundException"> </exception> Loading @@ -248022,7 +248009,7 @@ deprecated="not deprecated" visibility="public" > <parameter name="filename" type="java.lang.String"> <parameter name="path" type="java.lang.String"> </parameter> <parameter name="append" type="boolean"> </parameter> Loading Loading @@ -248693,7 +248680,7 @@ deprecated="not deprecated" visibility="public" > <parameter name="b" type="byte[]"> <parameter name="buffer" type="byte[]"> </parameter> <parameter name="offset" type="int"> </parameter> Loading Loading @@ -283770,9 +283757,9 @@ > <parameter name="dst" type="byte[]"> </parameter> <parameter name="off" type="int"> <parameter name="dstOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="byteCount" type="int"> </parameter> </method> <method name="get" Loading Loading @@ -284016,9 +284003,9 @@ > <parameter name="src" type="byte[]"> </parameter> <parameter name="off" type="int"> <parameter name="srcOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="byteCount" type="int"> </parameter> </method> <method name="put" Loading Loading @@ -284255,7 +284242,7 @@ </parameter> <parameter name="start" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="byteCount" type="int"> </parameter> </method> </class> Loading Loading @@ -284488,9 +284475,9 @@ > <parameter name="dst" type="char[]"> </parameter> <parameter name="off" type="int"> <parameter name="dstOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="charCount" type="int"> </parameter> </method> <method name="get" Loading Loading @@ -284588,9 +284575,9 @@ > <parameter name="src" type="char[]"> </parameter> <parameter name="off" type="int"> <parameter name="srcOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="charCount" type="int"> </parameter> </method> <method name="put" Loading Loading @@ -284719,7 +284706,7 @@ </parameter> <parameter name="start" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="charCount" type="int"> </parameter> </method> <method name="wrap" Loading Loading @@ -284880,9 +284867,9 @@ > <parameter name="dst" type="double[]"> </parameter> <parameter name="off" type="int"> <parameter name="dstOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="doubleCount" type="int"> </parameter> </method> <method name="get" Loading Loading @@ -284969,9 +284956,9 @@ > <parameter name="src" type="double[]"> </parameter> <parameter name="off" type="int"> <parameter name="srcOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="doubleCount" type="int"> </parameter> </method> <method name="put" Loading Loading @@ -285040,7 +285027,7 @@ </parameter> <parameter name="start" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="doubleCount" type="int"> </parameter> </method> </class> Loading Loading @@ -285171,9 +285158,9 @@ > <parameter name="dst" type="float[]"> </parameter> <parameter name="off" type="int"> <parameter name="dstOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="floatCount" type="int"> </parameter> </method> <method name="get" Loading Loading @@ -285260,9 +285247,9 @@ > <parameter name="src" type="float[]"> </parameter> <parameter name="off" type="int"> <parameter name="srcOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="floatCount" type="int"> </parameter> </method> <method name="put" Loading Loading @@ -285331,7 +285318,7 @@ </parameter> <parameter name="start" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="floatCount" type="int"> </parameter> </method> </class> Loading Loading @@ -285462,9 +285449,9 @@ > <parameter name="dst" type="int[]"> </parameter> <parameter name="off" type="int"> <parameter name="dstOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="intCount" type="int"> </parameter> </method> <method name="get" Loading Loading @@ -285551,9 +285538,9 @@ > <parameter name="src" type="int[]"> </parameter> <parameter name="off" type="int"> <parameter name="srcOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="intCount" type="int"> </parameter> </method> <method name="put" Loading Loading @@ -285622,7 +285609,7 @@ </parameter> <parameter name="start" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="intCount" type="int"> </parameter> </method> </class> Loading Loading @@ -285770,9 +285757,9 @@ > <parameter name="dst" type="long[]"> </parameter> <parameter name="off" type="int"> <parameter name="dstOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="longCount" type="int"> </parameter> </method> <method name="get" Loading Loading @@ -285859,9 +285846,9 @@ > <parameter name="src" type="long[]"> </parameter> <parameter name="off" type="int"> <parameter name="srcOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="longCount" type="int"> </parameter> </method> <method name="put" Loading Loading @@ -285930,7 +285917,7 @@ </parameter> <parameter name="start" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="longCount" type="int"> </parameter> </method> </class> Loading Loading @@ -286120,9 +286107,9 @@ > <parameter name="dst" type="short[]"> </parameter> <parameter name="off" type="int"> <parameter name="dstOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="shortCount" type="int"> </parameter> </method> <method name="get" Loading Loading @@ -286209,9 +286196,9 @@ > <parameter name="src" type="short[]"> </parameter> <parameter name="off" type="int"> <parameter name="srcOffset" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="shortCount" type="int"> </parameter> </method> <method name="put" Loading Loading @@ -286280,7 +286267,7 @@ </parameter> <parameter name="start" type="int"> </parameter> <parameter name="len" type="int"> <parameter name="shortCount" type="int"> </parameter> </method> </class>
core/java/android/database/sqlite/DatabaseConnectionPool.java +6 −8 Original line number Diff line number Diff line Loading @@ -246,17 +246,15 @@ import java.util.Random; } } /* package */ void setMaxPoolSize(int size) { synchronized(mParentDbObj) { /** only used for testing purposes. */ /* package */ synchronized void setMaxPoolSize(int size) { mMaxPoolSize = size; } } /* package */ int getMaxPoolSize() { synchronized(mParentDbObj) { /** only used for testing purposes. */ /* package */ synchronized int getMaxPoolSize() { return mMaxPoolSize; } } /** only used for testing purposes. */ /* package */ boolean isDatabaseObjFree(SQLiteDatabase db) { Loading
core/java/android/database/sqlite/SQLiteDatabase.java +36 −64 Original line number Diff line number Diff line Loading @@ -1048,14 +1048,16 @@ public class SQLiteDatabase extends SQLiteClosable { * Close the database. */ public void close() { if (!isOpen()) { return; // already closed } if (Log.isLoggable(TAG, Log.DEBUG)) { Log.i(TAG, "closing db: " + mPath + " (connection # " + mConnectionNum); } lock(); try { // some other thread could have closed this database while I was waiting for lock. // check the database state if (!isOpen()) { return; } closeClosable(); // finalize ALL statements queued up so far closePendingStatements(); Loading Loading @@ -2102,7 +2104,7 @@ public class SQLiteDatabase extends SQLiteClosable { return; } if (!isCacheFullWarningLogged() && mCompiledQueries.size() == mMaxSqlCacheSize) { if (!mCacheFullWarning && mCompiledQueries.size() == mMaxSqlCacheSize) { /* * cache size of {@link #mMaxSqlCacheSize} is not enough for this app. * log a warning. Loading @@ -2110,7 +2112,7 @@ public class SQLiteDatabase extends SQLiteClosable { */ Log.w(TAG, "Reached MAX size for compiled-sql statement cache for database " + getPath() + ". Use setMaxSqlCacheSize() to increase cachesize. "); setCacheFullWarningLogged(); mCacheFullWarning = true; } /* add the given SQLiteCompiledSql compiledStatement to cache. * no need to worry about the cache size - because {@link #mCompiledQueries} Loading @@ -2134,7 +2136,8 @@ public class SQLiteDatabase extends SQLiteClosable { * From the compiledQueries cache, returns the compiled-statement-id for the given SQL. * Returns null, if not found in the cache. */ /* package */ synchronized SQLiteCompiledSql getCompiledStatementForSql(String sql) { /* package */ SQLiteCompiledSql getCompiledStatementForSql(String sql) { synchronized (mCompiledQueries) { SQLiteCompiledSql compiledStatement = mCompiledQueries.get(sql); if (compiledStatement == null) { mNumCacheMisses++; Loading @@ -2143,6 +2146,7 @@ public class SQLiteDatabase extends SQLiteClosable { mNumCacheHits++; return compiledStatement; } } /** * Sets the maximum size of the prepared-statement cache for this database. Loading @@ -2159,7 +2163,7 @@ public class SQLiteDatabase extends SQLiteClosable { * the value set with previous setMaxSqlCacheSize() call. */ public void setMaxSqlCacheSize(int cacheSize) { synchronized(this) { synchronized(mCompiledQueries) { if (cacheSize > MAX_SQL_CACHE_SIZE || cacheSize < 0) { throw new IllegalStateException("expected value between 0 and " + MAX_SQL_CACHE_SIZE); } else if (cacheSize < mMaxSqlCacheSize) { Loading @@ -2176,14 +2180,6 @@ public class SQLiteDatabase extends SQLiteClosable { } } private synchronized boolean isCacheFullWarningLogged() { return mCacheFullWarning; } private synchronized void setCacheFullWarningLogged() { mCacheFullWarning = true; } private synchronized int getCacheHitNum() { return mNumCacheHits; } Loading Loading @@ -2279,7 +2275,8 @@ public class SQLiteDatabase extends SQLiteClosable { * * @return true if write-ahead-logging is set. false otherwise */ public synchronized boolean enableWriteAheadLogging() { public boolean enableWriteAheadLogging() { synchronized(this) { if (mPath.equalsIgnoreCase(MEMORY_DB_PATH)) { Log.i(TAG, "can't enable WAL for memory databases."); return false; Loading @@ -2300,6 +2297,7 @@ public class SQLiteDatabase extends SQLiteClosable { } return true; } } /** * This method disables the features enabled by {@link #enableWriteAheadLogging()}. Loading Loading @@ -2338,32 +2336,6 @@ public class SQLiteDatabase extends SQLiteClosable { } } /** * Sets the database connection handle pool size to the given value. * Database connection handle pool is enabled when the app calls * {@link #enableWriteAheadLogging()}. * <p> * The default connection handle pool is set by the system by taking into account various * aspects of the device, such as memory, number of cores etc. It is recommended that * applications use the default pool size set by the system. * * @param size the value the connection handle pool size should be set to. */ public void setConnectionPoolSize(int size) { synchronized(this) { if (mConnectionPool == null) { throw new IllegalStateException("connection pool not enabled"); } int i = mConnectionPool.getMaxPoolSize(); if (size < i) { throw new IllegalArgumentException( "cannot set max pool size to a value less than the current max value(=" + i + ")"); } mConnectionPool.setMaxPoolSize(size); } } /* package */ SQLiteDatabase createPoolConnection(short connectionNum) { SQLiteDatabase db = openDatabase(mPath, mFactory, mFlags, mErrorHandler, connectionNum); db.mParentConnObj = this; Loading
core/tests/coretests/src/android/database/sqlite/SQLiteDatabaseTest.java +1 −23 Original line number Diff line number Diff line Loading @@ -135,28 +135,6 @@ public class SQLiteDatabaseTest extends AndroidTestCase { c.close(); } @SmallTest public void testSetConnectionPoolSize() { mDatabase.enableWriteAheadLogging(); // can't set pool size to zero try { mDatabase.setConnectionPoolSize(0); fail("IllegalStateException expected"); } catch (IllegalArgumentException e) { assertTrue(e.getMessage().contains("less than the current max value")); } // set pool size to a valid value mDatabase.setConnectionPoolSize(10); assertEquals(10, mDatabase.mConnectionPool.getMaxPoolSize()); // can't set pool size to < the value above try { mDatabase.setConnectionPoolSize(1); fail("IllegalStateException expected"); } catch (IllegalArgumentException e) { assertTrue(e.getMessage().contains("less than the current max value")); } } /** * a transaction should be started before a standalone-update/insert/delete statement */ Loading Loading @@ -299,7 +277,7 @@ public class SQLiteDatabaseTest extends AndroidTestCase { if (useWal) { // set up connection pool mDatabase.enableWriteAheadLogging(); mDatabase.setConnectionPoolSize(i + 1); mDatabase.mConnectionPool.setMaxPoolSize(i + 1); } else { mDatabase.disableWriteAheadLogging(); } Loading