Problem in installing Dot Net Core 1.0.0 VS 2015 Tools Preview 2

Each time I try to install the DotNetCore.1.0.0-VS2015Tools.Preview2.exe package I get an error saying the following:

Setup Failed One or more issues caused the setup to fail. Please fix the issues and then retry setup. For more information see the log file. Setup has detected that Visual Studio 2015 Update 3 may not be completely installed. Please repair Visual Studio 2015 Update 3, then install this product again.

After changing the VS Community UpdateVersion string value from 14.0.25424 to 14.0.25420 in the registry, the installer worked fine for me

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\DevDiv\vs\Servicing\14.0\community
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\DevDiv\vs\Servicing\14.0\community\1033
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\DevDiv\vs\Servicing\14.0\ente‌rprise
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\DevDiv\vs\Servicing\14.0\ente‌rprise\1033

References :
http://stackoverflow.com/questions/38134048/problems-installing-dot-net-core-1-0-0-vs-2015-tools-preview-2

Use putExtra() and getExtra() for exchanging data between intents in Android Xamarin

Put Extra

Intent updateIntent = new Intent(this, typeof(UpdateActivity));
updateIntent.PutExtra("Version", update.LatestVersion);
updateIntent.PutExtra("Url", update.Url);
updateIntent.PutExtra("Length", length);
StartActivity(updateIntent);

GetExtra

protected override void OnCreate(Bundle savedInstanceState)
		{
			base.OnCreate(savedInstanceState);

			SetContentView(Resource.Layout.Update);


		    if (Intent.Extras != null)
		    {
                var version = Intent.Extras.GetString("Version");
                var url = Intent.Extras.GetString("Url");
                var length = Intent.Extras.GetLong("Length");
            }

		}

DownloadManager in Xamarin Android

Download Manager is a System Service that optimises the handling of long-running downloads in the background.

var download =(DownloadManager) GetSystemService(Context.DownloadService);
Android.Net.Uri uri=Android.Net.Uri.Parse(update.Url);
DownloadManager.Request request=new DownloadManager.Request(uri);
var fileName = System.IO.Path.GetFileName(update.Url);
request.SetTitle("Fan Coil").SetDescription(fileName);
request.SetVisibleInDownloadsUi(true);
request.SetNotificationVisibility(DownloadVisibility.VisibleNotifyCompleted);
download.Enqueue(request);
//request.SetAllowedNetworkTypes(DownloadNetwork.Mobile | DownloadNetwork.Wifi);

References :
http://101apps.co.za/articles/using-the-downloadmanager-to-manage-your-downloads.html
http://stackoverflow.com/questions/13349806/why-does-the-download-completed-notification-disappear-on-gingerbread-devices

Embed SQLite database file as Asset in Xamarin Android

At a glance:

1 – Add Sqlite.cs to your project.
2 – Add your database file as an Asset.
3 – Set your database file to build as an AndroidAsset.
4 – Manually copy the database file out of your apk to another directory.
5 – Open a database connetion using Sqlite.SqliteConnection.
6 – Operate on the database using Sqlite.

1. Add Sqlite.cs to your project.

2. Add DB as asset.
sqlite01

3. Set DB to build as AndroidAsset.
sqlite02

4. Manually copy DB out of your APK.

string dbName = "db.sqlite";
string dbPath = Path.Combine (Android.OS.Environment.ExternalStorageDirectory.ToString (), dbName);
// Check if your DB has already been extracted.
if (!File.Exists(dbPath))
{
    using (BinaryReader br = new BinaryReader(Assets.Open(dbName)))
    {
        using (BinaryWriter bw = new BinaryWriter(new FileStream(dbPath, FileMode.Create)))
        {
            byte[] buffer = new byte[2048];
            int len = 0;
            while ((len = br.Read(buffer, 0, buffer.Length)) > 0)
            {
                bw.Write (buffer, 0, len);
            }
        }
    }
}

5. Open DB Connection.

using (var conn = new SQLite.SQLiteConnection(dbPath))
{
        // Do stuff here...
}

6. Operate on DB.

References :
http://stackoverflow.com/questions/18715613/use-a-local-database-in-xamarin