-
-
Save horaceheaven/eafda691dd6be334bf92 to your computer and use it in GitHub Desktop.
MainActivity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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