Skip to content

Instantly share code, notes, and snippets.

@horaceheaven
Created August 17, 2014 01:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save horaceheaven/eafda691dd6be334bf92 to your computer and use it in GitHub Desktop.
Save horaceheaven/eafda691dd6be334bf92 to your computer and use it in GitHub Desktop.
MainActivity
public class MainActivity extends Activity {
/**
* The testOutOrmLiteDatabase method is called each time a new instance of the
* application is created.
* @param savedInstanceState
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
testOutOrmLiteDatabase();
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* Testing out the TodoOrmLiteExample app by creating some Todo entries in the database,
* and querying for all the Todo object from the todo table.
* @throws SQLException
*/
private void testOutOrmLiteDatabase() throws SQLException {
TodoOpenDatabaseHelper todoOpenDatabaseHelper = OpenHelperManager.getHelper(this,
TodoOpenDatabaseHelper.class);
Dao<Todo, Long> todoDao = todoOpenDatabaseHelper.getDao();
Date currDateTime = new Date(System.currentTimeMillis());
Calendar calendar = Calendar.getInstance();
calendar.setTime(currDateTime);
calendar.add(Calendar.DATE, 14);
Date dueDate = calendar.getTime();
todoDao.create(new Todo("Todo Example 1", "Todo Example 1 Description", currDateTime, dueDate));
todoDao.create(new Todo("Todo Example 2", "Todo Example 2 Description", currDateTime, dueDate));
todoDao.create(new Todo("Todo Example 3", "Todo Example 3 Description", currDateTime, dueDate));
List<Todo> todos = todoDao.queryForAll();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment