mirror of
				https://github.com/pierre42100/ComunicAndroid
				synced 2025-11-03 19:14:04 +00:00 
			
		
		
		
	Added friends list table to the mobile local database
This commit is contained in:
		
							
								
								
									
										2
									
								
								.idea/misc.xml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.idea/misc.xml
									
									
									
										generated
									
									
									
								
							@@ -55,7 +55,7 @@
 | 
				
			|||||||
    <ConfirmationsSetting value="0" id="Add" />
 | 
					    <ConfirmationsSetting value="0" id="Add" />
 | 
				
			||||||
    <ConfirmationsSetting value="0" id="Remove" />
 | 
					    <ConfirmationsSetting value="0" id="Remove" />
 | 
				
			||||||
  </component>
 | 
					  </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" />
 | 
					    <output url="file://$PROJECT_DIR$/build/classes" />
 | 
				
			||||||
  </component>
 | 
					  </component>
 | 
				
			||||||
  <component name="ProjectType">
 | 
					  <component name="ProjectType">
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,7 +15,7 @@ public final class DatabaseContract {
 | 
				
			|||||||
    public DatabaseContract(){}
 | 
					    public DatabaseContract(){}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Database basic information */
 | 
					    /* 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";
 | 
					    public static final String DATABASE_NAME = "database.db";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Users info table */
 | 
					    /* 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.SQLiteDatabase;
 | 
				
			||||||
import android.database.sqlite.SQLiteOpenHelper;
 | 
					import android.database.sqlite.SQLiteOpenHelper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.communiquons.android.comunic.client.data.DatabaseContract.FriendsListSchema;
 | 
				
			||||||
import org.communiquons.android.comunic.client.data.DatabaseContract.UsersInfoSchema;
 | 
					import org.communiquons.android.comunic.client.data.DatabaseContract.UsersInfoSchema;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@@ -38,8 +39,20 @@ public class DatabaseHelper extends SQLiteOpenHelper {
 | 
				
			|||||||
            UsersInfoSchema.TABLE_NAME;
 | 
					            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
 | 
					     * Public constructor
 | 
				
			||||||
@@ -57,12 +70,20 @@ public class DatabaseHelper extends SQLiteOpenHelper {
 | 
				
			|||||||
    public void onCreate(SQLiteDatabase db) {
 | 
					    public void onCreate(SQLiteDatabase db) {
 | 
				
			||||||
        //Create user informations table
 | 
					        //Create user informations table
 | 
				
			||||||
        db.execSQL(SQL_CREATE_USERS_INFOS_TABLE);
 | 
					        db.execSQL(SQL_CREATE_USERS_INFOS_TABLE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //Create friends list table
 | 
				
			||||||
 | 
					        db.execSQL(SQL_CREATE_FRIENDS_LIST_TABLE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
 | 
					    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
 | 
				
			||||||
        //Delete users informations table
 | 
					        //Delete users informations table
 | 
				
			||||||
        db.execSQL(SQL_DELETE_USERS_INFOS_TABLE);
 | 
					        db.execSQL(SQL_DELETE_USERS_INFOS_TABLE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //Delete friends list table
 | 
				
			||||||
 | 
					        db.execSQL(SQL_DELETE_FRIENDS_LIST_TABLE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //Perform creation table
 | 
				
			||||||
        onCreate(db);
 | 
					        onCreate(db);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user