Back to project page SpeechWriter.
The source code is released under:
MIT License
If you think the Android project SpeechWriter listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package edu.psu.rcy5017.speechwriter.datasource; //from ww w . java 2 s .c o m import java.util.List; import android.content.Context; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import edu.psu.rcy5017.speechwriter.DatabaseHelper; public abstract class DataSource<E> { private SQLiteDatabase database; private final DatabaseHelper dbHelper; public DataSource(Context context) { dbHelper = new DatabaseHelper(context); } public final void open() throws SQLException { database = getDbHelper().getWritableDatabase(); } public final void close() { getDbHelper().close(); } public final SQLiteDatabase getDatabase() { return database; } public final DatabaseHelper getDbHelper() { return dbHelper; } /** * Gets a list of all all of the elements in a table. * @param parentID the id of the parent that you are fetching from, use 0 if none. Example: if you are fetching note cards, the parentID would be the id of the speech that they belong to. * @return the list of elements */ public abstract List<E> getAll(long parentID); /** * Deletes an object from the table. * @param elementToDelete the object to delete */ public abstract void deleteObject(E elementToDelete); /** * Changes the order of the element in the database * @param elementToUpdate the element to change order * @param newOrder the new order of the element * @return the number of rows affected */ public abstract int ubdateOrder(E elementToUpdate, int newOrder); }