All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.gawst.asyncdb.InMemoryDbCopyOnWriteArrayList Maven / Gradle / Ivy

Go to download

A set of helper class to keep a copy of small SQLite databases in memory in Android

There is a newer version: 3.1.1
Show newest version
package org.gawst.asyncdb;

import java.util.concurrent.CopyOnWriteArrayList;

/**
 * a basic helper class to keep the content of a flat database in an {@link CopyOnWriteArrayList}
 * @author Steve Lhomme
 *
 * @param  the type of items stored in memory by the {@link InMemoryDbCopyOnWriteArrayList}
 */
public abstract class InMemoryDbCopyOnWriteArrayList extends InMemoryDbList, INSERT_ID> {

	/**
	 * the array where the data are stored, locked when writing on it
	 */
	private CopyOnWriteArrayList mData;

	/**
	 * @param db The already created {@link android.database.sqlite.SQLiteOpenHelper} to use as storage
	 * @param name Database name for logs
	 * @param logger The {@link org.gawst.asyncdb.Logger} to use for all logs (can be null for the default Android logs)
	 * @param initCookie Cookie to pass to {@link AsynchronousDbHelper#preloadInit(Object)}
	 */
	protected InMemoryDbCopyOnWriteArrayList(DataSource db, String name, Logger logger, Object initCookie) {
		super(db, name, logger, initCookie);
	}
	
	@Override
	protected void preloadInit(Object cookie) {
		super.preloadInit(cookie);
		mData = new CopyOnWriteArrayList();
	}
	
	@Override
	protected CopyOnWriteArrayList getList() {
		return mData;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy