Back to project page ShareList-Android.
The source code is released under:
GNU General Public License
If you think the Android project ShareList-Android 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 org.mybop.sharelist.app.database; // w w w. j av a 2s. c o m import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.util.Log; import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper; import com.j256.ormlite.support.ConnectionSource; import com.j256.ormlite.table.TableUtils; import org.mybop.sharelist.app.database.entity.ElementEntity; import org.mybop.sharelist.app.database.entity.ListEntity; import java.io.File; import java.io.InputStream; import java.sql.SQLException; /** * Created by gautier on 11/03/2014. */ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { private static final String LOGGER_TAG = DatabaseHelper.class.getSimpleName(); private static final String DATABASE_NAME = "share_list.db"; private static final int DATABASE_VERSION = 1; public DatabaseHelper(Context context) { this(context, null); } public DatabaseHelper(Context context, SQLiteDatabase.CursorFactory factory) { super(context, DATABASE_NAME, factory, DATABASE_VERSION); } public DatabaseHelper(Context context, SQLiteDatabase.CursorFactory factory, int configFileId) { super(context, DATABASE_NAME, factory, DATABASE_VERSION, configFileId); } public DatabaseHelper(Context context, SQLiteDatabase.CursorFactory factory, File configFile) { super(context, DATABASE_NAME, factory, DATABASE_VERSION, configFile); } public DatabaseHelper(Context context, SQLiteDatabase.CursorFactory factory, InputStream stream) { super(context, DATABASE_NAME, factory, DATABASE_VERSION, stream); } @Override public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) { try { Log.d(LOGGER_TAG, "creating table \"list\""); TableUtils.createTable(connectionSource, ListEntity.class); Log.d(LOGGER_TAG, "creating table \"element\""); TableUtils.createTable(connectionSource, ElementEntity.class); } catch (SQLException e) { Log.e(LOGGER_TAG, "unable to create tables", e); } } @Override public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) { } }