本文整理汇总了Java中com.j256.ormlite.table.TableUtils.createTable方法的典型用法代码示例。如果您正苦于以下问题:Java TableUtils.createTable方法的具体用法?Java TableUtils.createTable怎么用?Java TableUtils.createTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.j256.ormlite.table.TableUtils
的用法示例。
在下文中一共展示了TableUtils.createTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTable
import com.j256.ormlite.table.TableUtils; //导入方法依赖的package包/类
private void createTable(SQLiteDatabase db, ConnectionSource connectionSource) {
try {
TableUtils.createTable(connectionSource, MyPhoto.class);
TableUtils.createTable(connectionSource, MyMoment.class);
TableUtils.createTable(connectionSource, MyMomentPhoto.class);
TableUtils.createTable(connectionSource, MyFace.class);
TableUtils.createTable(connectionSource, MyFacePhoto.class);
TableUtils.createTable(connectionSource, UploadedPhoto.class);
TableUtils.createTable(connectionSource, MyAlbum.class);
TableUtils.createTable(connectionSource, MyAlbumPhoto.class);
TableUtils.createTable(connectionSource, MyTag.class);
TableUtils.createTable(connectionSource, MyTagPhoto.class);
TableUtils.createTable(connectionSource, MyCursor.class);
TableUtils.createTable(connectionSource, MySetting.class);
} catch (Exception e) {
Log.e(DatabaseHelper.class.getName(), "Can't create database", e);
e.printStackTrace();
}
}
示例2: onCreate
import com.j256.ormlite.table.TableUtils; //导入方法依赖的package包/类
@Override
public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
try {
TableUtils.createTable(connectionSource, AirQualityLive.class);
TableUtils.createTable(connectionSource, WeatherForecast.class);
TableUtils.createTable(connectionSource, LifeIndex.class);
TableUtils.createTable(connectionSource, WeatherLive.class);
TableUtils.createTable(connectionSource, Weather.class);
String weatherTrigger = "CREATE TRIGGER trigger_delete AFTER DELETE " +
"ON Weather " +
"FOR EACH ROW " +
"BEGIN " +
"DELETE FROM AirQuality WHERE cityId = OLD.cityId; " +
"DELETE FROM WeatherLive WHERE cityId = OLD.cityId; " +
"DELETE FROM WeatherForecast WHERE cityId = OLD.cityId; " +
"DELETE FROM LifeIndex WHERE cityId = OLD.cityId; " +
"END;";
database.execSQL(weatherTrigger);
} catch (SQLException e) {
e.printStackTrace();
}
}
示例3: onCreate
import com.j256.ormlite.table.TableUtils; //导入方法依赖的package包/类
/**
* 创建数据库时会回调的接口,在这个方法里面完成对数据库表的创建
*/
@Override
public void onCreate(SQLiteDatabase db, ConnectionSource connectionSource)
{
try
{
Log.I(TAG, "--------------------- onCreate ---------------------");
TableUtils.createTable(connectionSource, Like.class);
// 数据初始化
initDatabase(db, connectionSource);
}
catch (SQLException e)
{
Log.E(TAG, "Can't create database.", e);
throw new RuntimeException(e);
}
}
示例4: onCreate
import com.j256.ormlite.table.TableUtils; //导入方法依赖的package包/类
/**
* 创建数据库时会回调的接口,在这个方法里面完成对数据库表的创建
*/
@Override
public void onCreate(SQLiteDatabase db, ConnectionSource connectionSource) {
try {
Log.I(TAG, "--------------------- onCreate ---------------------");
TableUtils.createTable(connectionSource, AlbumInfo.class);
TableUtils.createTable(connectionSource, PhotoInfo.class);
// 数据初始化
initDatabase(db, connectionSource);
} catch (SQLException e) {
Log.E(TAG, "Can't create database.", e);
throw new RuntimeException(e);
}
}
示例5: onCreate
import com.j256.ormlite.table.TableUtils; //导入方法依赖的package包/类
/**
* Creates the DB scheme and tables
*/
private void onCreate() {
try {
Log.i(TAG_LOG, "DB onCreate");
// List of tables to be created
TableUtils.createTable(connectionSource, Song.class);
TableUtils.createTable(connectionSource, Playlist.class);
TableUtils.createTable(connectionSource, Alarm.class);
Log.i(TAG_LOG, "DB successfully created");
} catch (SQLException e) {
Log.e(TAG_LOG, "An error has occurred while creating the DB", e);
throw new RuntimeException(e);
}
}
示例6: onCreate
import com.j256.ormlite.table.TableUtils; //导入方法依赖的package包/类
@Override
public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
try {
TableUtils.createTable(connectionSource, PoiType.class);
TableUtils.createTable(connectionSource, Constraint.class);
TableUtils.createTable(connectionSource, Source.class);
TableUtils.createTable(connectionSource, Condition.class);
TableUtils.createTable(connectionSource, Action.class);
TableUtils.createTable(connectionSource, PoiTypeTag.class);
TableUtils.createTable(connectionSource, Poi.class);
TableUtils.createTable(connectionSource, PoiTag.class);
TableUtils.createTable(connectionSource, PoiNodeRef.class);
TableUtils.createTable(connectionSource, Note.class);
TableUtils.createTable(connectionSource, Comment.class);
TableUtils.createTable(connectionSource, MapArea.class);
} catch (SQLException e) {
Timber.e(e, "Error while creating tables");
}
}
示例7: onCreate
import com.j256.ormlite.table.TableUtils; //导入方法依赖的package包/类
@Override
public void onCreate(SQLiteDatabase db, ConnectionSource connectionSource) {
try {
Log.i(Constant.TAG, "onCreate");
TableUtils.createTable(connectionSource, ItemGridModel.class);
TableUtils.createTable(connectionSource, AuthorModel.class);
TableUtils.createTable(connectionSource, ClassRoomModel.class);
TableUtils.createTable(connectionSource, TypeModel.class);
TableUtils.createTable(connectionSource, DayModel.class);
TableUtils.createTable(connectionSource, TimeModel.class);
TableUtils.createTable(connectionSource, AboutModel.class);
}
catch (SQLException e) {
Log.e(Constant.TAG, "Can't create database", e);
throw new RuntimeException(e);
}
}
示例8: onCreate
import com.j256.ormlite.table.TableUtils; //导入方法依赖的package包/类
/**
* This is called when the database is first created. Usually you should call createTable statements here to create
* the tables that will store your data.
*/
@Override
public void onCreate(SQLiteDatabase db, ConnectionSource connectionSource) {
try {
Log.i(DatabaseHelper.class.getName(), "onCreate");
TableUtils.createTable(connectionSource, SimpleData.class);
} catch (SQLException e) {
Log.e(DatabaseHelper.class.getName(), "Can't create database", e);
throw new RuntimeException(e);
}
// here we try inserting data in the on-create as a test
RuntimeExceptionDao<SimpleData, Integer> dao = getSimpleDataDao();
long millis = System.currentTimeMillis();
// create some entries in the onCreate
SimpleData simple = new SimpleData(millis);
dao.create(simple);
simple = new SimpleData(millis + 1);
dao.create(simple);
Log.i(DatabaseHelper.class.getName(), "created new entries in onCreate: " + millis);
}
示例9: onCreate
import com.j256.ormlite.table.TableUtils; //导入方法依赖的package包/类
@Override
public void onCreate (SQLiteDatabase db, ConnectionSource source)
{
Log.d("DatabaseService", "onCreate");
try
{
TableUtils.createTable(connectionSource, Workout.class);
TableUtils.createTable(connectionSource, Exercise.class);
TableUtils.createTable(connectionSource, Session.class);
XmlNode root = new XmlNode(getResources().getXml(R.xml.trainings_default));
XmlNode workouts = root.getChildren("workouts").get(0);
for (XmlNode n : workouts.getChildren("workout"))
Workout.fromXml(n);
}
catch (Exception e)
{
throw new DatabaseAccessException("failed to access database", e);
}
}
示例10: onCreate
import com.j256.ormlite.table.TableUtils; //导入方法依赖的package包/类
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase,
ConnectionSource connectionSource) {
// Here, TableUtils will use the Annotations on our classes to create
// all of
// the tables in our relation.
try {
/*
* When using foreign keys, we must be sure to create tables in the
* proper order. For example, since the ArticleCategory table has
* foreign keys to both the Article and Category tables, we must
* declare ArticleCategory after the two others.
*/
TableUtils.createTable(connectionSource, GameList.class);
TableUtils.createTable(connectionSource, GameTeam.class);
TableUtils.createTable(connectionSource, GameTeammember.class);
TableUtils.createTable(connectionSource, GameResult.class);
TableUtils.createTable(connectionSource, GameResultStatistic.class);
} catch (SQLException e) {
Log.e(TAG, "Unable to create tables.", e);
throw new RuntimeException(e);
}
}
示例11: onCreate
import com.j256.ormlite.table.TableUtils; //导入方法依赖的package包/类
/**
* This is called when the database is first created. Usually you should
* call createTable statements here to create the tables that will store
* your data.
*/
@Override
public void onCreate(SQLiteDatabase db, ConnectionSource connectionSource) {
try {
if(BuildConfig.DEBUG) Log.i(DatabaseHelper.class.getName(), "onCreate");
TableUtils.createTable(connectionSource, SearchRecordRecentInfo.class);
// here we try inserting data in the on-create as a test
/*
* Dao<Article, Integer> dao = getArticleDao(); long millis =
* System.currentTimeMillis(); // create some entries in the
* onCreate Article simple = new Article(millis);
* dao.create(simple); simple = new Article(millis + 1);
* dao.create(simple);
*/
} catch (SQLException e) {
if(BuildConfig.DEBUG) Log.e(DatabaseHelper.class.getName(), "Can't create database", e);
throw new RuntimeException(e);
}
}
示例12: onCreate
import com.j256.ormlite.table.TableUtils; //导入方法依赖的package包/类
@Override
public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
try {
TableUtils.createTable(connectionSource, MyBusinessInfLocal.class);
TableUtils.createTable(connectionSource, MyDownloadInfLocal.class);
} catch (SQLException e) {
e.printStackTrace();
}
}
示例13: createTable
import com.j256.ormlite.table.TableUtils; //导入方法依赖的package包/类
public void createTable(Class<?> classObject) {
try {
TableUtils.createTable(getConnectionSource(), classObject);
} catch (SQLException e) {
Log.d(DatabaseHelper.class.getName(), "Can't create database", e);
throw new RuntimeException(e);
}
}
示例14: onCreate
import com.j256.ormlite.table.TableUtils; //导入方法依赖的package包/类
@Override
public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
try {
TableUtils.createTable(connectionSource, Champion.class);
} catch (SQLException e) {
Log.e(DbHelperImpl.class.getName(), "Error, unable to create table");
}
}
示例15: onCreate
import com.j256.ormlite.table.TableUtils; //导入方法依赖的package包/类
@Override
public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
try {
Log.d(this.getClass().getName(), "onCreate");
TableUtils.createTable(connectionSource, Task.class);
} catch (SQLException e) {
Log.e(this.getClass().getName(), "Can't create database", e);
throw new RuntimeException(e);
}
}