Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

In a Xamarin-Android project, after overwriting from a sqlite file, program shows no new data.

$
0
0

In a Xamarin-Android project, after overwriting from a sqlite file, program shows no new data.
Early everything was ok. Can you help me?

In App.cs:

var _db_path = DependencyService.Get<IFileAccessHelper>().GetLocalFilePath(m_db_name);
 g_database = new SQLiteAsyncConnection(_db_path);
 articlesItem_database = new ArticlesItemDatabase(g_database);

....

public static ArticlesItemDatabase ArticlesItemDatabase
{
    get
    {
        if (articlesItem_database == null)
        {
              var _tmp = DependencyService.Get<IFileAccessHelper>().GetLocalFilePath(m_db_name);
              articlesItem_database = new ArticlesItemDatabase(g_database);  // _tmp);
        }
        return articlesItem_database;
    }
 }

In "ArticlesItemDatabase":

public class ArticlesItemDatabase
    {
        SQLiteAsyncConnection m_database;

        public ArticlesItemDatabase(SQLiteAsyncConnection Connection) 
        {
            m_database = Connection;                              
            m_database.CreateTableAsync<ArticlesItem>().Wait();
        }
...
}

In MainActivity.cs:

public bool RestoreDBFromAssetsDB(string currentDBPathName, string db_test_name)
        {
            try
            {
                Stream _stream = m_assets.Open(db_test_name);
                var _byte_arr = MainActivity.StreamToByteArray(_stream);
                System.IO.File.WriteAllBytes(currentDBPathName, _byte_arr);

                return true;
            }
            catch (System.IO.IOException ex)
            {
                UserDialogs.Instance.AlertAsync(ex.Message, AppResources.error);
                Crashes.TrackError(ex);
                return false;
            }

Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>