Android Open Source - roodroid Conversations Helper






From Project

Back to project page roodroid.

License

The source code is released under:

Copyright (c) 2011, Jonathan Perichon & Lucas Gerbeaux Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"...

If you think the Android project roodroid 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 fr.utbm.roodroid.client;
//from  w w w .jav  a2  s .  c o  m
import fr.utbm.roodroid.ApplicationManager;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

/**
 * ConversationsHelper
 * Extends SQLiteOpenHelper
 * 
 * Manages database creation and version management for the Conversations.
 *  
 * @author Jonathan Perichon <jonathan.perichon@gmail.com>
 * @author Lucas Gerbeaux <lucas.gerbeaux@gmail.com>
 *
 */
public class ConversationsHelper extends SQLiteOpenHelper {

  public static final String TAB_CONV = "conversations";
  public static final String COL_CONVID = "_id";
  public static final String COL_CONVCONTACTPHONENUMBER = "contact_phone_number";
  public static final String COL_CONVCONTACTNAME = "contact_name";
  
  public static final String TAB_MSG = "messages";
  public static final String COL_MSGID = "_id";
  public static final String COL_MSGIDCONV = "_id_conv";
  public static final String COL_MSGDATE = "date";
  public static final String COL_MSGCONTENT = "content";
  public static final String COL_MSGSTATUS = "status";
  public static final String COL_MSGTYPE = "type";

  private static final String DB_NAME = "messages.db";
  private static final int DB_VERSION = 11;
  private static final String MSG_CREATE = "create table "
      + TAB_MSG + "( "
      + COL_MSGID + " integer primary key autoincrement, "
      + COL_MSGIDCONV + " integer not null, "
      + COL_MSGDATE + " integer not null, "
      + COL_MSGSTATUS + " integer not null, "
      + COL_MSGTYPE + " integer not null, "
      + COL_MSGCONTENT + " text not null, "
      + "foreign key(" + COL_MSGIDCONV + ") references "+ TAB_CONV +"(" + COL_CONVID + ") on delete cascade )";
  
  private static final String CONV_CREATE = "create table "
      + TAB_CONV + "( "
      + COL_CONVID + " integer primary key autoincrement, "
      + COL_CONVCONTACTPHONENUMBER + " text not null, "
      + COL_CONVCONTACTNAME + " text not null )";

  public ConversationsHelper() {
    super(ApplicationManager.getInstance().getApplicationContext(), DB_NAME, null, DB_VERSION);
  }

  @Override
  public void onCreate(SQLiteDatabase database) {
    database.execSQL(MSG_CREATE);
    database.execSQL(CONV_CREATE);
  }

  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    Log.w(ConversationsHelper.class.getName(),
        "Upgrading database from version " + oldVersion + " to "
            + newVersion + ", which will destroy all old data");
    db.execSQL("DROP TABLE IF EXISTS " + TAB_MSG);
    db.execSQL("DROP TABLE IF EXISTS " + TAB_CONV);
    onCreate(db);
  }

}




Java Source Code List

fr.utbm.roodroid.ApplicationManager.java
fr.utbm.roodroid.ConnectionBluetooth.java
fr.utbm.roodroid.ConnectionWifi.java
fr.utbm.roodroid.Connection.java
fr.utbm.roodroid.Conversation.java
fr.utbm.roodroid.Message.java
fr.utbm.roodroid.PacketClient.java
fr.utbm.roodroid.Packet.java
fr.utbm.roodroid.TCPCommandType.java
fr.utbm.roodroid.TextMessage.java
fr.utbm.roodroid.activity.AuthorizedUsernamesAdapter.java
fr.utbm.roodroid.activity.BluetoothDiscovery.java
fr.utbm.roodroid.activity.ClientBluetoothSettings.java
fr.utbm.roodroid.activity.ClientWifiSettings.java
fr.utbm.roodroid.activity.ConversationsAdapter.java
fr.utbm.roodroid.activity.ConversationsList.java
fr.utbm.roodroid.activity.LogPage.java
fr.utbm.roodroid.activity.MessagesAdapter.java
fr.utbm.roodroid.activity.MessagesList.java
fr.utbm.roodroid.activity.ProfileTypeChooser.java
fr.utbm.roodroid.activity.ServerAdvancedSettings.java
fr.utbm.roodroid.activity.ServerBluetoothMain.java
fr.utbm.roodroid.activity.ServerBluetoothSettings.java
fr.utbm.roodroid.activity.ServerWifiMain.java
fr.utbm.roodroid.activity.ServerWifiSettings.java
fr.utbm.roodroid.client.ClientBluetooth.java
fr.utbm.roodroid.client.ClientWifi.java
fr.utbm.roodroid.client.Client.java
fr.utbm.roodroid.client.ConversationsDataSource.java
fr.utbm.roodroid.client.ConversationsHelper.java
fr.utbm.roodroid.server.AuthByID.java
fr.utbm.roodroid.server.AuthByPassword.java
fr.utbm.roodroid.server.AuthMethod.java
fr.utbm.roodroid.server.AuthNone.java
fr.utbm.roodroid.server.ServerBluetooth.java
fr.utbm.roodroid.server.ServerWifi.java
fr.utbm.roodroid.server.Server.java