Java Code Examples for com.j256.ormlite.table.TableUtils#clearTable()

The following examples show how to use com.j256.ormlite.table.TableUtils#clearTable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DatabaseHelper.java    From AndroidAPS with GNU Affero General Public License v3.0 5 votes vote down vote up
public void deleteAllDbRequests() {
    try {
        TableUtils.clearTable(connectionSource, DbRequest.class);
    } catch (SQLException e) {
        log.error("Unhandled exception", e);
    }
}
 
Example 2
Source File: InviteDao.java    From FamilyChat with Apache License 2.0 5 votes vote down vote up
/**
 * 清楚表中所有数据
 */
public void clear()
{
    try
    {
        TableUtils.clearTable(getDao().getConnectionSource(), InviteBean.class);
    } catch (SQLException e)
    {
        KLog.e(TAG + "InviteDao.clear fail:" + e.toString());
    }
}
 
Example 3
Source File: DbHelperUtils.java    From q-municate-android with Apache License 2.0 5 votes vote down vote up
public static void clearTable(ConnectionSource connectionSource, Class clazz) {
    try {
        TableUtils.clearTable(connectionSource, clazz);
    } catch (SQLException e) {
        ErrorUtils.logError(e);
    }
}
 
Example 4
Source File: DbHelperUtils.java    From q-municate-android with Apache License 2.0 5 votes vote down vote up
public static void clearTable(ConnectionSource connectionSource, Class clazz) {
    try {
        TableUtils.clearTable(connectionSource, clazz);
    } catch (SQLException e) {
        ErrorUtils.logError(e);
    }
}
 
Example 5
Source File: FlowDatabaseHelper.java    From flow-android with MIT License 5 votes vote down vote up
/**
 * Call this method to delete all entries in the database
 *
 * @param connectionSource
 */
public static void clearDatabase(ConnectionSource connectionSource){
    try {
        TableUtils.clearTable(connectionSource, User.class);
        TableUtils.clearTable(connectionSource, Course.class);
        TableUtils.clearTable(connectionSource, ScheduleCourse.class);
        TableUtils.clearTable(connectionSource, Exam.class);
        TableUtils.clearTable(connectionSource, UserCourse.class);
        TableUtils.clearTable(connectionSource, ScheduleImage.class);
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
 
Example 6
Source File: LocalSqliteDriverImpl.java    From mae-annotation with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setTaskName(String name) throws MaeDBException {
    try {
        // need to clear task table before updating id column of it
        TableUtils.clearTable(cs, taskDao.getDataClass());
        workingTask.setName(name);
        taskDao.create(workingTask);
    } catch (SQLException e) {
        throw catchSQLException(e);
    }
}
 
Example 7
Source File: PersistManager.java    From Man-Man with GNU General Public License v3.0 5 votes vote down vote up
public void clearAllTables() {
    try {
        TableUtils.clearTable(DbProvider.getHelper().getConnectionSource(), ManSectionItem.class);
        TableUtils.clearTable(DbProvider.getHelper().getConnectionSource(), ManSectionIndex.class);
        TableUtils.clearTable(DbProvider.getHelper().getConnectionSource(), ManPage.class);
    } catch (SQLException e) {
        throw new RuntimeException(e);
    }
}
 
Example 8
Source File: DemoDataGenerator.java    From Notification-Analyser with MIT License 5 votes vote down vote up
public void Generate(boolean emptyFirst) {
    if (!hasGenerated) {
        try {
            ApplicationDao daoApp = getDatabaseHelper().getApplicationDao();
            NotificationItemDao daoNtf = getDatabaseHelper().getNotificationDao();

            if (emptyFirst) {
                TableUtils.clearTable(getDatabaseHelper().getConnectionSource(), Application.class);
                TableUtils.clearTable(getDatabaseHelper().getConnectionSource(), NotificationItem.class);
            }

            for (AppMock app : apps) {
                daoApp.create(app.application);
            }

            for (int i = 0; i < notificationsAmount; i++) {
                AppMock a = GenerateApplication();
                NotificationItem ntf = new NotificationItem(a.application.getPackageName(), dates.get(i), GenerateApplicationMessage(a));
                daoNtf.create(ntf);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        this.close();
    } else {
        hasGenerated = true;
    }
}
 
Example 9
Source File: ORMLiteIntegrationTest.java    From tutorials with MIT License 4 votes vote down vote up
@After
public void clear() throws SQLException {
    TableUtils.clearTable(connectionSource, Library.class);
    TableUtils.clearTable(connectionSource, Book.class);
    TableUtils.clearTable(connectionSource, Address.class);
}
 
Example 10
Source File: DatabaseHandler.java    From AndroidBase with Apache License 2.0 2 votes vote down vote up
/**
 * 清除表数据
 *
 * @throws SQLException
 */
public void clear(ConnectionSource connectionSource) throws SQLException {
    TableUtils.clearTable(connectionSource, clazz);
}