Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Pass data from class to another activity.

Xammy10Xammy10 Member ✭✭✭

I'm creating a login that if the user log's in, his/her data will be passed to another activity. BTW I'm using SQLite as my database.

Here is my class:

public class person
{
[PrimaryKey, AutoIncrement]
public int id { get; set; }
[MaxLength(25)]
public string fname { get; set; }
[MaxLength(15)]
public string lname { get; set; }
[MaxLength(500)]
public byte[] image { get; set; }
[MaxLength(15)]
public string email { get; set; }
[MaxLength(15)]
public string num { get; set; }
[MaxLength(15)]
public string uname { get; set; }
[MaxLength(15)]
public string pword { get; set; }
}

I want the ID to be passed to activity2, so that the activity2 will recognized who's the person who log's in. Then the activity2 will display all of the data of that user who own's the ID.

I try using put extra, but the value I used is static(fixed data). what i want to pass is the value from my SQLite Database

Can you give me some example, links or source code?

Thanks in advance :)

Best Answer

Answers

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    post your code

  • ChristopheBERNARDChristopheBERNARD BEMember ✭✭✭✭✭

    Hello all,
    @Enohara

    if you have the id of the user, make just a query on your sql lite database locate in the device as this for exemple.
    create for exemple a manager (class) who make a getOne, getall, insert, update, delete and so on ...

    `
    public static FakeModelUser GetOne(int id)
    {
    FakeModelUser user = null;
    try
    {
    //
    SQLiteConnection db = new SQLiteConnection(AppWine.Utils.Constans.GetPathToDatabase());

                //
                FakeModelUser = db.Table<FakeModelUser>().Where(x => x.ID == id).FirstOrDefault();
            }
            catch (SQLiteException e)
            {
                Log.Error("WINECommand.GetOne", e.Message);
                Log.Error("WINECommand.GetOne", e.ToString());
            }
            return theCommand;
        }
    

    `

Sign In or Register to comment.