當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。