Android Open Source - SimpleTwitterClient Sample Model

From Project

Back to project page SimpleTwitterClient.


The source code is released under:

Copyright (c) 2014 Keithen Hayenga Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the So...

If you think the Android project SimpleTwitterClient listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.codepath.apps.basictwitter.models;
//from w w w  .j  a v  a 2 s  .c o m
import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;

import com.activeandroid.Model;
import com.activeandroid.annotation.Column;
import com.activeandroid.annotation.Table;
import com.activeandroid.query.Select;

 * This is a temporary, sample model that demonstrates the basic structure
 * of a SQLite persisted Model object. Check out the ActiveAndroid wiki for more details:
@Table(name = "items")
public class SampleModel extends Model {
  // Define table fields
  @Column(name = "name")
  private String name;
  public SampleModel() {
  // Parse model from JSON
  public SampleModel(JSONObject object){

    try { = object.getString("title");
    } catch (JSONException e) {
  // Getters
  public String getName() {
    return name;
  // Record Finders
  public static SampleModel byId(long id) {
     return new Select().from(SampleModel.class).where("id = ?", id).executeSingle();
  public static List<SampleModel> recentItems() {
      return new Select().from(SampleModel.class).orderBy("id DESC").limit("300").execute();

Java Source Code List