当前位置: 首页>>代码示例>>Java>>正文


Java TableUtils.createTable方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:aliyun,项目名称:aliyun-cloudphotos-android-demo,代码行数:20,代码来源:DatabaseHelper.java

示例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();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:WeatherDatabaseHelper.java

示例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);
	}
	
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:23,代码来源:LocalDbCacheHelper.java

示例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);
	}

}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:20,代码来源:DatabaseHelper.java

示例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);
  }
}
 
开发者ID:aajn88,项目名称:wakemeapp,代码行数:19,代码来源:DatabaseHelper.java

示例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");
    }
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:20,代码来源:OsmSqliteOpenHelper.java

示例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);
    }

}
 
开发者ID:clovisjunior,项目名称:ftsl_app,代码行数:19,代码来源:DatabaseHelper.java

示例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);
}
 
开发者ID:stephanenicolas,项目名称:ormlite-android-gradle-plugin,代码行数:25,代码来源:DatabaseHelper.java

示例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);
    }
}
 
开发者ID:oaken-source,项目名称:exceer,代码行数:21,代码来源:DatabaseService.java

示例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);
	}
}
 
开发者ID:bitjjj,项目名称:GameRecorder,代码行数:24,代码来源:DatabaseHelper.java

示例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);
	}
}
 
开发者ID:simplelifetian,项目名称:GomeOnline,代码行数:25,代码来源:DatabaseHelper.java

示例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();
  }
}
 
开发者ID:lifengsofts,项目名称:AndroidDownloader,代码行数:10,代码来源:DBHelper.java

示例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);
	}

}
 
开发者ID:ByteWelder,项目名称:Poetry,代码行数:10,代码来源:DatabaseHelper.java

示例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");
    }
}
 
开发者ID:Ryuuke,项目名称:LeagueOfAndroid,代码行数:9,代码来源:DbHelperImpl.java

示例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);
    }

}
 
开发者ID:seeing-eye,项目名称:UnforgetIt,代码行数:12,代码来源:DataBaseJPAHelper.java


注:本文中的com.j256.ormlite.table.TableUtils.createTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。