コード例 #1
0
ファイル: Events.java プロジェクト: acsuit/GiraffeEvents
 private Cursor getEvents() {
   // Perform a managed query. The Activity will handle closing
   // and re-querying the cursor when needed.
   SQLiteDatabase db = events.getReadableDatabase();
   Cursor cursor = db.query(TABLE_NAME, FROM, null, null, null, null, ORDER_BY);
   startManagingCursor(cursor);
   return cursor;
 }
コード例 #2
0
ファイル: Events.java プロジェクト: acsuit/GiraffeEvents
 private void addEvent(String string, int score) {
   // Insert a new record into the Events data source.
   // You would do something similar for delete and update.
   SQLiteDatabase db = events.getWritableDatabase();
   ContentValues values = new ContentValues();
   values.put(NAME, string);
   values.put(TIME, System.currentTimeMillis());
   values.put(SCORE, score);
   db.insertOrThrow(TABLE_NAME, null, values);
 }
コード例 #3
0
ファイル: Events.java プロジェクト: acsuit/GiraffeEvents
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   events = new EventsData(this);
   try {
     addEvent("Anna", (int) Math.round(20 * Math.random()));
     addEvent("Violeta", (int) Math.round(20 * Math.random()));
     Cursor cursor = getEvents();
     showEvents(cursor);
   } finally {
     events.close();
   }
 }