mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 13:59:29 +00:00
Added friends list table to the mobile local database
This commit is contained in:
parent
5c8d8a8f52
commit
2f9184c5dc
@ -55,7 +55,7 @@
|
||||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
@ -15,7 +15,7 @@ public final class DatabaseContract {
|
||||
public DatabaseContract(){}
|
||||
|
||||
/* Database basic information */
|
||||
public static final int DATABASE_VERSION = 1;
|
||||
public static final int DATABASE_VERSION = 2;
|
||||
public static final String DATABASE_NAME = "database.db";
|
||||
|
||||
/* Users info table */
|
||||
@ -29,4 +29,15 @@ public final class DatabaseContract {
|
||||
|
||||
}
|
||||
|
||||
/* Friends list table */
|
||||
public static abstract class FriendsListSchema implements BaseColumns {
|
||||
public static final String TABLE_NAME = "friends_list";
|
||||
|
||||
public static final String COLUMN_NAME_FRIEND_ID = "friend_id";
|
||||
public static final String COLUMN_NAME_FRIEND_ACCEPTED = "accepted";
|
||||
public static final String COLUMN_NAME_FRIEND_FOLLOWING = "following";
|
||||
public static final String COLUMN_NAME_FRIEND_LAST_ACTIVITY = "last_activity";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
import org.communiquons.android.comunic.client.data.DatabaseContract.FriendsListSchema;
|
||||
import org.communiquons.android.comunic.client.data.DatabaseContract.UsersInfoSchema;
|
||||
|
||||
/**
|
||||
@ -38,8 +39,20 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||
UsersInfoSchema.TABLE_NAME;
|
||||
|
||||
|
||||
/**
|
||||
* Creation and deletion of the friends table
|
||||
*/
|
||||
private static final String SQL_CREATE_FRIENDS_LIST_TABLE =
|
||||
"CREATE TABLE " + FriendsListSchema.TABLE_NAME + " (" +
|
||||
FriendsListSchema._ID + " INTEGER PRIMARY KEY," +
|
||||
FriendsListSchema.COLUMN_NAME_FRIEND_ID + INTEGER_TYPE + COMMA_SEP +
|
||||
FriendsListSchema.COLUMN_NAME_FRIEND_ACCEPTED + INTEGER_TYPE + COMMA_SEP +
|
||||
FriendsListSchema.COLUMN_NAME_FRIEND_FOLLOWING + INTEGER_TYPE + COMMA_SEP +
|
||||
FriendsListSchema.COLUMN_NAME_FRIEND_LAST_ACTIVITY + INTEGER_TYPE +
|
||||
" )";
|
||||
|
||||
|
||||
private static final String SQL_DELETE_FRIENDS_LIST_TABLE = "DROP TABLE IF EXISTS " +
|
||||
FriendsListSchema.TABLE_NAME;
|
||||
|
||||
/**
|
||||
* Public constructor
|
||||
@ -57,12 +70,20 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
//Create user informations table
|
||||
db.execSQL(SQL_CREATE_USERS_INFOS_TABLE);
|
||||
|
||||
//Create friends list table
|
||||
db.execSQL(SQL_CREATE_FRIENDS_LIST_TABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
//Delete users informations table
|
||||
db.execSQL(SQL_DELETE_USERS_INFOS_TABLE);
|
||||
|
||||
//Delete friends list table
|
||||
db.execSQL(SQL_DELETE_FRIENDS_LIST_TABLE);
|
||||
|
||||
//Perform creation table
|
||||
onCreate(db);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user