本文整理匯總了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);
}
}