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; }
public string fname { get; set; }
public string lname { get; set; }
public byte[] image { get; set; }
public string email { get; set; }
public string num { get; set; }
public string uname { get; set; }
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


  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    post your code

  • ChristopheBERNARDChristopheBERNARD BEMember ✭✭✭✭✭

    Hello all,

    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;
    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.