I'm trying to sync data between a webserver and an android app.So, i'm following this great advice: Sync data between Android App and webserver
Now, i'm actually working in the first part doing the Content Provider. For this, i found this tutorial: http://www.vogella.com/articles/AndroidSQLite/article.html
And in that tutorial they suggest that you should do one SQLiteOpenHelper for each table. It was working okay for me, but i realized that it was a bit odd, because i'll have one file for each table
Like this:
public class AppUserDatabaseHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "appusertable.db";
private static final int DATABASE_VERSION = 1;
public AppUserDatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
// Method is called during creation of the database
@Override
public void onCreate(SQLiteDatabase database) {
AppUserTable.onCreate(database);
}
}
So, i started to do some research and i found out this: Should there be one SQLiteOpenHelper for each table in the database? and this link in particular: http://blog.foxxtrot.net/2009/01/a-sqliteopenhelper-is-not-a-sqlitetablehelper.html , and that makes a lot of sense to me.
Well, my problem is that actually it also makes a lot of sence to have one ContentProvider for each table, because if i don't it will be huge and very confusing, but in every ContentProvider is where i'm actually creating the database:
public class AppUserContentProvider extends ContentProvider {
@Override
public boolean onCreate() {
database = new AppUserDatabaseHelper(getContext());
return false;
}
}
And this also gives me access to the database.
So my question is: I just should do a giant ContentProvider for all tables? or there is another way to create the database that should be shared between every ContentProvider?
I hope you can help me Thanks in advice