SQlite Xamarin forms Visual Studio 2019 Local Database

Majid Sarrouh 1 Reputation point
2021-01-19T14:15:51.853+00:00

Hiiiiiiiiiii

I designed an app that I published in the google play store
The app uses aLocal database (SQlite) to enable the user to register once and use the app for a limited period of 1 year only.
But...
the problem is that when a user installs my app, he can easily go to the settings of his Android phone, click on Apps
then look for the installed app
and click on Storage

and
Clear All Data
stored in the local database

by doing so, he will be able to use it again as if it is the first time.

So the trial period is useless in this case

HOW to disable the "Clear All Data" in the storage?

NOTE: If we cannot disable the clear data option beecause it's a function of the device how can we save the data in a way that cannot be erased in a LOCAL SQLITE DATABASE.

Is there a way???????????

Please help

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,366 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,153 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,117 questions
0 comments No comments
{count} votes

6 answers

Sort by: Most helpful
  1. JarvanZhang 23,961 Reputation points
    2021-01-20T09:50:46.257+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    Where did you store the database? In Android, external storage has two different ways: public and private files. Private files are files that are specific to your application, these files will be removed when uninstalling the application or clearing the application data.

    Public files that are not considered to be specific to the application and are meant to be freely shared. These files will not be removed if you uninstall the app. To keep the database when clearing the application data, try to store the database as the public path.

    Check the doc:
    https://learn.microsoft.com/en-us/xamarin/android/platform/files/external-storage?tabs=windows#public-external-files

    Best Regards,

    Jarvan Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    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.


  2. Majid Sarrouh 1 Reputation point
    2021-01-22T16:33:57.763+00:00

    Can you put these codes in a sample very simple project done with Visual Studio Community version (2019) Xamarin forms Please?

    The first Page that opens when the app icon is clicked is a called LoginPage.xaml
    It contains a sub page called LoginPage.xaml.cs containing the code that when run allows the user to enter the email address and his name just the first time the app is run after installation.
    At this first time run, the data and time are stored in the public file and will be used anytime later the app is opened again

    The second time the app is opened, the code in the LoginPage.xaml.cs contains a code that when run allows the user to;

    1- either go to a new page called HomePage.xaml and start using the app IF THE DIFFERENCE IN DATE IS LESS THAN 1 MONTH (difference between the stored date and the current date when the app is accessed the second time)
    2- stay in the same page and a message box will be displayed announcing the end of the trial period

    ALL THE CODES ARE WRITTEN AND RUNNING CORRECTLY WITHOUT ANY PROBLEM BUT JUST THE CODE WRITTEN IN THE LoginPage.xaml.cs STORES THE DATE IN SQLite database and this date can be deleted when the storage section of the app is accessed in the phone setting and Data is Cleared. This is what I do not want to happen.

    0 comments No comments

  3. Majid Sarrouh 1 Reputation point
    2021-01-25T12:29:29.537+00:00

    Can you put these codes in a sample very simple project done with Visual Studio Community version (2019) Xamarin forms Please?

    The first Page that opens when the app icon is clicked is a called LoginPage.xaml
    It contains a sub page called LoginPage.xaml.cs containing the code that when run allows the user to enter the email address and his name just the first time the app is run after installation.
    At this first time run, the data and time are stored in the public file and will be used anytime later the app is opened again

    The second time the app is opened, the code in the LoginPage.xaml.cs contains a code that when run allows the user to;

    1- either go to a new page called HomePage.xaml and start using the app IF THE DIFFERENCE IN DATE IS LESS THAN 1 MONTH (difference between the stored date and the current date when the app is accessed the second time)
    2- stay in the same page and a message box will be displayed announcing the end of the trial period

    ALL THE CODES ARE WRITTEN AND RUNNING CORRECTLY WITHOUT ANY PROBLEM BUT JUST THE CODE WRITTEN IN THE LoginPage.xaml.cs STORES THE DATE IN SQLite database and this date can be deleted when the storage section of the app is accessed in the phone setting and Data is Cleared. This is what I do not want to happen.


  4. Majid Sarrouh 1 Reputation point
    2021-01-25T19:02:27.237+00:00

    Good Day
    I hope my email finds you well.
    Hope you and your families are safe and in good health

    I am Majid Sarrouh, Chemistry Teacher in the German International School Beirut, Lebanon. I have 25 years of experience in teaching Chemistry for students at

    the Secondary level (Grades 10, 11 and 12). I have a great passion for Chemistry to help students build their skills and confidence. I am fond of Computer

    Programing and I have advanced skills in the use of Technology in Teaching. I taught IB Chemistry courses at SL and HL for 13 years and I am an assistant

    examiner in the International Baccalaureate Organization. I have been marking examination papers since 2008 till the present time.
    I would like to announce the release of my Educational Chemistry App in the Google Play Store working on Android mobile phones and Tablets.

    CompuChem: Solutions to Most Quantitative Chemistry Problems
    Kindly find below the link to the App
    https://play.google.com/store/apps/details?id=com.CompuChem.myapp

    CompuChemLite: Solutions to Most Quantitative Chemistry Problems - FREE VERSION TO TRY SOME FEATURES
    Kindly find below the link to the App
    https://play.google.com/store/apps/details?id=com.CompuChemLite.myapp

    Please kindly Hit the "Like" buttons for the 7 Videos in the Playlist and "Subscribe" to my Channel after watching the videos and learning more about the

    CompuChem App:

    https://www.youtube.com/watch?

    reload=9&v=jxelinCBoPA&list=PLSR6HAl8he6xbD9hca6sxfzOFIbkbsuHX&fbclid=IwAR2SqbKEDpTuippfksJZu476WDAVMO8QHpD4wBmpuQpaaPwKWLBC

    -s-zVxI

    I designed the CompuChem to help the users to find answers/verify answers for commonly asked quantitative questions and exercises in almost all Chemistry topics

    studied at school level in Grades 10, 11 and 12.

    A student can benefit from this application as well as a teacher. I wrote a Manual of 393 pages to help the students get the most out of this app. The manual includes

    all the operations that this app is capable of doing and a detailed solution for each operation. Each example is an exercise in Quantitative Chemistry. So, this app

    can serve as a private tutor for students to teach them how to get correct answers in Quantitative Chemistry.

    Students can enter their data for any exercise that this app can solve and get answers and work on the exercise to see if they will reach the same output. If not, they

    can check the manual to see how they are expected to proceed to get correct answers.

    Hopefully, you are kindly asked to share this email with all Students in Grades 10, 11 and 12 you are in contact with and with ALL Chemistry teachers also. Your

    cooperation is well appreciated and beneficial to students and teachers all over the world.

    Topics covered in the App:
    1.Atomic Structure, Isotopes
    2.Ions and Ionic Compounds
    3.Converting mass to moles and vice versa
    4.Converting number of particles to moles and vice versa
    5.The Three Gas Laws: Algebraic and Graphical studies
    6.Converting volume of gases to moles and vice versa
    7.Ideal Gas Equation
    8.Molarity, moles of solute and Volume of solution
    9.Concentration by mass, mass of solute and volume
    10.% by mass of solute, mass of solute and mass of solution
    11.Molarity related to density (solution) and % by mass (solute)
    12.Dilution Principle of Aqueous solutions
    13.Empirical Formula of Compounds
    14.Molecular Formula of Compounds
    15.Combustion Analysis of Organic Compounds
    16.Families of Organic Compounds
    17.Stoichiometry: Metal + Acid reactions
    18.Galvanic or Voltaic Cells
    19.Chemical Equilibrium: Synthesis of Ammonia and Esterification
    20.Chemical Kinetics: Decomposition of Hydrogen peroxide
    21.Acids and Bases
    22.Thermochemistry: Calorimetry
    23.Soaps and Saponification reactions

    Good Work and Best Wishes for Brilliant Success in Chemistry
    MAJID SARROUH
    CHEMISTRY TEACHER
    COMPUCHEM DEVELOPER

    =====================================================================================================================

    Based on the Request of friends and Chemistry teachers in different schools in Lebanon and Europe that I contacted and I informed them about CompuChem, a

    Free Version is released to be tried by Chemistry Teachers and Students taking a Chemistry course in Grades 10, 11 and 12

    CompuChemLite: Solutions to Most Quantitative Chemistry Problems - FREE VERSION TO TRY SOME FEATURES
    Kindly find below the link to the App
    https://play.google.com/store/apps/details?id=com.CompuChemLite.myapp

    CompuChemLite App is a FREE App released for trial purpose including 4 applications to try:
    1- Gas Laws: Algebraic and Graphical Studies
    2- Relation between % by mass of solutes in aqueous solutions, Density of solutions and Molarity of solutes in aqueous solutions
    3- Empirical Formula of Compounds
    4- Chemical Equilibrium Study

    Install the App on your Android mobile or Android Tablet, Open the App and Fill in your Email address to receive from me a manual explaining in details how the 4

    applications mentioned above are used and detailed solutions for Chemistry Exercises solved using the Applications

    Hopefully, you are kindly asked to share this message with all Students in Grades 10, 11 and 12 you are in contact with and with ALL Chemistry teachers also. Your

    cooperation is well appreciated and beneficial to students and teachers all over the world.

    Good Work and Best Wishes for Brilliant Success in Chemistry
    MAJID SARROUH
    CHEMISTRY TEACHER
    COMPUCHEM DEVELOPER

    0 comments No comments

  5. Majid Sarrouh 1 Reputation point
    2021-01-26T19:15:28.52+00:00

    Dear JarvanZhang

    Yes I am facing some troubles with implementing the code you suggested to me. I have limited knowleedge in databases connected to apps and I just need to store ONE Date in an external file the first time my app is used by a user and each time the app is accessed the app will compare the current date to the stored date and if the difference is less that 1 month, the used is allowed to access and if not the access is denied.

    In the first time the date is to be stored in the external public file, when the user is asked to give permission to store or not the date, if he does not accept the user will not be granted access to the app.

    Kindly find attached some pictures of the errors faced60682-errors-to-fix.png


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.