Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.gawst.asyncdb;
 
 import  android.content.ContentValues;

Interface to define a data source with E elements.

Parameters:
<E> Elements read/written by the data source.
<INSERT_ID> Type of the object returned by insert(android.content.ContentValues)
Author(s):
Created by robUx4 on 12/31/2014.
public interface DataSource<E, INSERT_ID> {

Internal interface to handle elements when the whole database is read.

Parameters:
<E>
	public interface BatchReadingCallback<E> {
Add the element in the memory storage

Parameters:
item The object to add
		void addItemInMemory(E item);

Called when we have the cursor to read the data from.

Useful to prepare the amount of data needed or get the index of the column we need.

Parameters:
elementCount The amount of elements that are about to be read from the database.
		void startLoadingAllItems(int elementCount);
		void removeInvalidEntry(InvalidEntry invalidEntry);
	}

Internal call to read the whole database.

Parameters:
readingCallback
Returns:
All the elements in the source with all the fields
	void queryAll(BatchReadingCallback<E> readingCallback);

Clear all the data in the source

Returns:
the number of items removed
	int clearAllData();

Add a new element in the source

Parameters:
element The element to add
Returns:
An object representing the added item or null if it wasn't added
	INSERT_ID insert(ContentValues elementthrows RuntimeException;

Delete the item from the source of data

Parameters:
itemToDelete
Returns:
1 if the element was removed, 0 otherwise
	int delete(E itemToDelete);

Delete the data specified by the invalidEntry from the source.

Parameters:
invalidEntry
Returns:
	boolean deleteInvalidEntry(InvalidEntry invalidEntry);

Update an element already in the database

Parameters:
itemToUpdate
updateValues
Returns:
true if the element was updated
	boolean update(E itemToUpdate, ContentValues updateValues);

Completely delete the data source, likely because it's corrupted beyond repair
	void eraseSource();
New to GrepCode? Check out our FAQ X