Android Open Source - MyTwitter-Android My Twitter D B






From Project

Back to project page MyTwitter-Android.

License

The source code is released under:

Apache License

If you think the Android project MyTwitter-Android 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 org.fukata.android.mytw.database;
/* w ww  .j a v a  2 s  . c  o m*/
import org.fukata.android.mytw.database.schema.TweetSchema;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class MyTwitterDB extends SQLiteOpenHelper {
  final static String TAG = MyTwitterDB.class.getSimpleName();
  
  final static String DB_NAME = "mytw.db";
  final static int DB_VERSION = 2;

  static MyTwitterDB db;
  
  public static MyTwitterDB getInstance(Context context) {
    if ( db == null ) {
      db = new MyTwitterDB(context);
    }
    return db;
  }
  
  private MyTwitterDB(Context context) {
    super(context, DB_NAME, null, DB_VERSION);
  }

  @Override
  public void onCreate(SQLiteDatabase db) {
    try {
      db.beginTransaction();

      // tweets
      Log.i(TAG, "create tweets");
      db.execSQL(
          "CREATE TABLE " + TweetSchema.TABLE + " ( " + 
          TweetSchema.ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + 
          TweetSchema.STATUS_ID + " TEXT, " + 
          TweetSchema.STATUS + " TEXT, " + 
          TweetSchema.USERNAME + " TEXT, " + 
          TweetSchema.USER_ID + " TEXT, " + 
          TweetSchema.SOURCE + " TEXT, " + 
          TweetSchema.IN_REPLY_TO_STATUS_ID + " TEXT, " + 
          TweetSchema.CREATED_AT + " INTEGER, " +
          TweetSchema.TWEET_TYPE + " INTEGER, " +
          TweetSchema.CUSTOM + " TEXT " +
          ");"
      );
      
      db.setTransactionSuccessful();
    } finally {
      db.endTransaction();
    }
  }

  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    Log.i(getClass().getSimpleName(), "Schema Update old:" + oldVersion + " new:" + newVersion);
    if( oldVersion == 1 && newVersion == 2 ) {
            db.execSQL("ALTER TABLE " + TweetSchema.TABLE + " ADD COLUMN " 
                + TweetSchema.IN_REPLY_TO_STATUS_ID + " TEXT"
                + ";" );
    }
  }

}




Java Source Code List

org.fukata.android.mytw.DirectMessageTimelineAdapter.java
org.fukata.android.mytw.DirectMessageTimelineView.java
org.fukata.android.mytw.HomeTimelineView.java
org.fukata.android.mytw.MentionTimelineView.java
org.fukata.android.mytw.MyTwitterActivity.java
org.fukata.android.mytw.MyTwitterApp.java
org.fukata.android.mytw.SettingsActivity.java
org.fukata.android.mytw.TimelineActivity.java
org.fukata.android.mytw.TimelineAdapter.java
org.fukata.android.mytw.TimelineItem.java
org.fukata.android.mytw.TimelineView.java
org.fukata.android.mytw.UpdateStatusActivity.java
org.fukata.android.mytw.database.MyTwitterDB.java
org.fukata.android.mytw.database.dao.BaseDao.java
org.fukata.android.mytw.database.dao.TweetDao.java
org.fukata.android.mytw.database.dto.TweetDto.java
org.fukata.android.mytw.database.schema.TweetSchema.java
org.fukata.android.mytw.receiver.InstallAnalyticsReceiver.java
org.fukata.android.mytw.twitter.Twitter.java
org.fukata.android.mytw.twitter.rs.Status.java
org.fukata.android.mytw.twitter.rs.User.java
org.fukata.android.mytw.util.PrettyDateUtil.java
org.fukata.android.mytw.util.SettingUtil.java
org.fukata.android.mytw.util.StringMatchUtils.java
org.fukata.android.mytw.util.StringUtils.java