One content provider for all your tables works fine.
I don't know if that's the best way to do it but i'm using a content
provider as a dao container managing the state of my database connection and
providing access to DAOs that are responsible each of them of one table.
Besides, each DAO extends a GenericDAO<T> abstract class that provide access
to a T type of objects.
class userDAO extends GenericDAO<User> { ...}
and for the code that is similar i'm putting it in a GenericDAO with some
hook that are to be implemented by each DAO.
abstract T createObjectFromCursor(Cursor cursor);
abstract String[] getColumnNames();
abstract String getTableName();
abstract ContentValues getContentValuesForObject(T);
The generic DAO provide some utils methods like public T findObjectById(long
id)
or ArrayList<T> findObjectsListByWhereClause(string where, ArrayList<T>
list);
And some others...
Arnaud
2009/4/27 JUN <[email protected]>
>
> hi all, I'm viewing the Notepad Tutorial.
> i have a question, if my database have two tables. should i create two
> custom content providers for two tables?
>
> if it is, i think it's not good. the two providers is similar of
> codes.
>
> Or other how to do it?
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---