Work offline when there is no internet connection

I have created the xamrin.ios app with sqlserver 2014 database. Used the api method to do the DDL and DML operations. The app is working fine when it is connected via network.

Now the challenge when there is network issue, the app stopped working.

Question:
How the app works when it is offline (when network not available)?
Do we need to create the offline database in the app itself, the current app usages the complex stored procs with temporary tables, how do we sync when the app connected to the network?
Do I need to create the all c# methods again to work with local database?

Any ideas how we can handle this.

Best Answer

Answers

  • HarshitaHarshita INMember ✭✭✭✭

    @sudhirbharti.5023
    Hello,
    If you want to work with offline mode.then follow few steps
    1)Install SQLIte in your app
    2)Implement all database connection and create database tables.
    3)when you call the api then check trhe internet connectivity,if internet not available then save this data to local database.
    4)create a background service and implement a timer so that it will check the internet connectivity with every minute or any timespan which you define in your timer.And fetch the data from your table and send it to server with api call.and make sure that when the post api response true then delete the data from local database.

  • @Harshita said:
    @sudhirbharti.5023
    Hello,
    If you want to work with offline mode.then follow few steps
    1)Install SQLIte in your app
    2)Implement all database connection and create database tables.
    3)when you call the api then check trhe internet connectivity,if internet not available then save this data to local database.
    4)create a background service and implement a timer so that it will check the internet connectivity with every minute or any timespan which you define in your timer.And fetch the data from your table and send it to server with api call.and make sure that when the post api response true then delete the data from local database.

    Thanks for the reply Harshita,

    So we need to create the complete database as local database, what about the sql procedure? How do we will sync if connection established?

  • @Harshita said:
    @sudhirbharti.5023
    Hello,
    1)Install Xam.Plugin.Connectivity from nuget.(Add the namespace using Plugin.Connectivity;)

    Check the internet connectivity:
    public static bool IsNetWorkAvail(int type)
    {
    bool response = false;
    try
    {
    if (!CrossConnectivity.Current.IsConnected)
    {
    response = false;
    }
    else
    {
    response = true;
    }
    }
    catch (Exception ex)
    {

    }
    return response;
    }

    then implement your code. :)

    How do I handle the stored procedure in xamarin using SQlite? The stored procedure having 100s of line in it.

  • divyagarimelladivyagarimella Member ✭✭

    @sudhirbharti.5023 hi you can try akavache in xamarin

Sign In or Register to comment.