jeudi 30 avril 2015

C# Android How to check if Database exists or not

I ve made a registration page for my app, it creates a database when submitted. The registration page should only open once, if it is filled then it should move on to the main activity. Here I have used File.Exists command to check if the database file exists or not.

namespace Mind
{
 using System.Threading;

using Android.App;
using Android.OS;

[Activity(Theme = "@style/Theme.Splash", Icon = "@drawable/icon", MainLauncher = true, NoHistory = true)]
public class SplashActivity : Activity
{

    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);
        Thread.Sleep(500); // Simulate a long loading process on app startup.

        const string fileName = "@/data/data/http://ift.tt/1bhnQ3C";

            if (File.Exists (fileName)) {
            StartActivity (typeof(MainActivity));
        } else {
            StartActivity (typeof(Registration));
        } 


    }
  }
}

but no success, there are no errors but it always shows the Registration page after the splash screen

Aucun commentaire:

Enregistrer un commentaire