How create database and connect to xamarin android project ?

Shay Wilner 1,746 Reputation points
2023-06-11T20:48:04.7833333+00:00

Hello

I would like to create a database and to use it in a xamarin android project

I don't know which kind of project i need in the visual studio 2022 i have

idb

Developer technologies .NET Xamarin
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,126 Reputation points Microsoft External Staff
    2023-06-13T02:35:39.2766667+00:00

    Hello,

    i don't intend to create a sql server project in fact i need a very simple database with only 1 table.

    Depending on your needs, creating a database using Android's built-in SQLlite engine will be a better choice.

    You could refer to the following documentation and code sample:

    Although the above sample code was created early, the section on database operations is still available.

    You could refer to the code in the ORM section to build your own database in your project, and save and query the database in the following way.

    Stock s = new Stock();
    s.Id = 0;
    s.Name = "test";
    s.Symbol = "test";
    // save
    StockRepository.SaveStock(s);
    // get all items from database.
    var list = StockRepository.GetStocks();
    

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.