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


Java RuntimeExceptionDao.create方法代码示例

本文整理汇总了Java中com.j256.ormlite.dao.RuntimeExceptionDao.create方法的典型用法代码示例。如果您正苦于以下问题:Java RuntimeExceptionDao.create方法的具体用法?Java RuntimeExceptionDao.create怎么用?Java RuntimeExceptionDao.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.j256.ormlite.dao.RuntimeExceptionDao的用法示例。


在下文中一共展示了RuntimeExceptionDao.create方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initDatabase

import com.j256.ormlite.dao.RuntimeExceptionDao; //导入方法依赖的package包/类
/**
 * 数据初始化
 */
private void initDatabase() {
	RuntimeExceptionDao<FocusItemInfo, Long> koItemInfoDao = getFocusItemInfoDao();
	int length = BusinessData.LOCAL_ALBUM_FOCUS.length;
	int itemCount = BusinessData.LOCAL_ALBUM_FOCUS[0].length;

	FocusItemInfo itemInfo = null;
	for (int i = 0; i < length; i++) {
		itemInfo = new FocusItemInfo();
		itemInfo.setData(BusinessData.LOCAL_ALBUM_FOCUS[i][0]);
		itemInfo.setBucket_display_name(BusinessData.LOCAL_ALBUM_FOCUS[i][1]);
		itemInfo.setBeautiful_name(BusinessData.LOCAL_ALBUM_FOCUS[i][2]);
		itemInfo.setIcon(BusinessData.LOCAL_ALBUM_FOCUS[i][3]);

		itemInfo.setSystem(true);
		// 系统自带索引1000开始, 用户添加的应当排在最前面.
		itemInfo.setOrder_by(1000 + i);

		koItemInfoDao.create(itemInfo);
	}
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:24,代码来源:UserDatabaseHelper.java

示例2: initDatabase

import com.j256.ormlite.dao.RuntimeExceptionDao; //导入方法依赖的package包/类
/**
 * 数据初始化
 */
private void initDatabase()
{
	RuntimeExceptionDao<FocusItemInfo, Long> koItemInfoDao = getFocusItemInfoDao();
	int length = BusinessData.LOCAL_ALBUM_FOCUS.length;
	int itemCount = BusinessData.LOCAL_ALBUM_FOCUS[0].length;
	
	FocusItemInfo itemInfo = null;
	for (int i = 0; i < length; i++)
	{
		itemInfo = new FocusItemInfo();
		itemInfo.setData(BusinessData.LOCAL_ALBUM_FOCUS[i][0]);
		itemInfo.setBucket_display_name(BusinessData.LOCAL_ALBUM_FOCUS[i][1]);
		itemInfo.setBeautiful_name(BusinessData.LOCAL_ALBUM_FOCUS[i][2]);
		itemInfo.setIcon(BusinessData.LOCAL_ALBUM_FOCUS[i][3]);
		
		itemInfo.setSystem(true);
		// 系统自带索引1000开始, 用户添加的应当排在最前面.
		itemInfo.setOrder_by(1000 + i);
		
		koItemInfoDao.create(itemInfo);
	}
}
 
开发者ID:benniaobuguai,项目名称:android-project-wo2b,代码行数:26,代码来源:UserDatabaseHelper.java

示例3: createIfNotExists

import com.j256.ormlite.dao.RuntimeExceptionDao; //导入方法依赖的package包/类
private void createIfNotExists(RuntimeExceptionDao<ICal, Long> iCalDao, ICal iCal)
{
    List<ICal> retrievedICals = new ArrayList<>();
    QueryBuilder<ICal, Long> queryBuilder = iCalDao.queryBuilder();
    try {
        queryBuilder.where().eq("summery", iCal.getSummery()).and().eq("start", iCal.getStart())
        .and().eq("end", iCal.getEnd());
    } catch (SQLException e) {
        e.printStackTrace();
    }

    if(retrievedICals.size() == 0)
    {
        iCalDao.create(iCal);
    }
}
 
开发者ID:FAU-Inf2,项目名称:fablab-android,代码行数:17,代码来源:ICalModel.java

示例4: onCreate

import com.j256.ormlite.dao.RuntimeExceptionDao; //导入方法依赖的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

示例5: onOptionsItemSelected

import com.j256.ormlite.dao.RuntimeExceptionDao; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
  // action with ID action_refresh was selected
  case R.id.add:
    Toast.makeText(this, "Add selected", Toast.LENGTH_SHORT).show();
    RuntimeExceptionDao<ChordData, Integer> simpleDao = getHelper().getSimpleDataDao();
    ChordData chord = new ChordData("draft (added)", -1, -1, -1, -1, -1, -1);
    simpleDao.create(chord);
    showDetail(Integer.toString(chord.id));
    break;
  // action with ID action_settings was selected
    /*
  case R.id.action_settings:
    Toast.makeText(this, "Settings selected", Toast.LENGTH_SHORT)
        .show();
    break;
    */
  default:
    break;
  }

  return true;
}
 
开发者ID:trapridge,项目名称:MEng,代码行数:25,代码来源:ChordListActivity.java

示例6: onCreate

import com.j256.ormlite.dao.RuntimeExceptionDao; //导入方法依赖的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, ChordData.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<ChordData, Integer> dao = getSimpleDataDao();
	long millis = System.currentTimeMillis();
	// create some entries in the onCreate
	ChordData simple = new ChordData("initial", -1, -1, -1, -1, -1, -1);
	dao.create(simple);
	simple = new ChordData("initial2", -1, -1, -1, -1, -1, -1);
	dao.create(simple);
	Log.i(DatabaseHelper.class.getName(), "created new entries in onCreate: " + millis);
}
 
开发者ID:trapridge,项目名称:MEng,代码行数:25,代码来源:DatabaseHelper.java

示例7: initDatabase_BAK

import com.j256.ormlite.dao.RuntimeExceptionDao; //导入方法依赖的package包/类
/**
 * 数据初始化
 */
private void initDatabase_BAK() {
	RuntimeExceptionDao<FocusItemInfo, Long> koItemInfoDao = getFocusItemInfoDao();
	int length = BusinessData.LOCAL_FOCUS_PARENT_DIRECTORY.length;
	int itemCount = BusinessData.LOCAL_FOCUS_PARENT_DIRECTORY[0].length;

	String sdcard_root = null;

	if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
		File sdcard_dir = Environment.getExternalStorageDirectory();
		sdcard_root = sdcard_dir.getPath();
	}

	FocusItemInfo itemInfo = null;
	for (int i = 0; i < length; i++) {
		itemInfo = new FocusItemInfo();
		itemInfo.setData(sdcard_root + BusinessData.LOCAL_ALBUM_FOCUS[i][0]);
		itemInfo.setBucket_display_name(BusinessData.LOCAL_ALBUM_FOCUS[i][1]);
		itemInfo.setBeautiful_name(BusinessData.LOCAL_ALBUM_FOCUS[i][1]);
		itemInfo.setIcon(BusinessData.LOCAL_ALBUM_FOCUS[i][2]);

		itemInfo.setSystem(true);
		// 系统自带索引1000开始, 用户添加的应当排在最前面.
		itemInfo.setOrder_by(1000 + i);

		koItemInfoDao.create(itemInfo);
	}
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:31,代码来源:UserDatabaseHelper.java

示例8: initDatabase_BAK

import com.j256.ormlite.dao.RuntimeExceptionDao; //导入方法依赖的package包/类
/**
 * 数据初始化
 */
private void initDatabase_BAK()
{
	RuntimeExceptionDao<FocusItemInfo, Long> koItemInfoDao = getFocusItemInfoDao();
	int length = BusinessData.LOCAL_FOCUS_PARENT_DIRECTORY.length;
	int itemCount = BusinessData.LOCAL_FOCUS_PARENT_DIRECTORY[0].length;

	String sdcard_root = null;

	if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
	{
		File sdcard_dir = Environment.getExternalStorageDirectory();
		sdcard_root = sdcard_dir.getPath();
	}
	
	FocusItemInfo itemInfo = null;
	for (int i = 0; i < length; i++)
	{
		itemInfo = new FocusItemInfo();
		itemInfo.setData(sdcard_root + BusinessData.LOCAL_ALBUM_FOCUS[i][0]);
		itemInfo.setBucket_display_name(BusinessData.LOCAL_ALBUM_FOCUS[i][1]);
		itemInfo.setBeautiful_name(BusinessData.LOCAL_ALBUM_FOCUS[i][1]);
		itemInfo.setIcon(BusinessData.LOCAL_ALBUM_FOCUS[i][2]);

		itemInfo.setSystem(true);
		// 系统自带索引1000开始, 用户添加的应当排在最前面.
		itemInfo.setOrder_by(1000 + i);

		koItemInfoDao.create(itemInfo);
	}
}
 
开发者ID:benniaobuguai,项目名称:android-project-wo2b,代码行数:34,代码来源:UserDatabaseHelper.java

示例9: createIfNotExists

import com.j256.ormlite.dao.RuntimeExceptionDao; //导入方法依赖的package包/类
private void createIfNotExists(RuntimeExceptionDao<News, Long> newsDao, News news)
{
    List<News> retrievedNews = newsDao.queryForEq("title", news.getTitle());

    if(retrievedNews.size() == 0)
    {
        newsDao.create(news);
    }
}
 
开发者ID:FAU-Inf2,项目名称:fablab-android,代码行数:10,代码来源:NewsModel.java

示例10: create

import com.j256.ormlite.dao.RuntimeExceptionDao; //导入方法依赖的package包/类
@Override
public <T> void create(@NotNull final T object) {
    if (!(object instanceof OrmLiteModel)) {
        throw new IllegalArgumentException("Only OrmLiteModel instances are supported.");
    }

    RuntimeExceptionDao dao = getRuntimeExceptionDao(object.getClass());
    dao.create(object);
}
 
开发者ID:nhaarman,项目名称:PebbleNotifier,代码行数:10,代码来源:OrmLiteDatabaseHelper.java


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