From 7cffa9a3c365412a89fc713e81b2ab50fd362840 Mon Sep 17 00:00:00 2001 From: Philipp Crocoll Date: Tue, 6 Jan 2015 03:59:46 +0100 Subject: [PATCH] added checks to ensure existing files are returned. fixes an issue with opening files from gdrive on Android 4.4+ through system file manager --- src/keepass2android/Utils/Util.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/keepass2android/Utils/Util.cs b/src/keepass2android/Utils/Util.cs index 81e9521b..a5a4555b 100644 --- a/src/keepass2android/Utils/Util.cs +++ b/src/keepass2android/Utils/Util.cs @@ -18,6 +18,7 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file using System; using System.Collections; using System.Collections.Generic; +using System.IO; using Android.App; using Android.Content; using Android.Database; @@ -200,7 +201,9 @@ namespace keepass2android ICursor c1 = ctx.ContentResolver.Query(uri, col, null, null, null); c1.MoveToFirst(); - return c1.GetString(0); + var possibleFilename = c1.GetString(0); + if (File.Exists(possibleFilename)) + return possibleFilename; } } catch (Exception e) @@ -209,7 +212,7 @@ namespace keepass2android } String filename = data.Data.Path; - if (String.IsNullOrEmpty(filename)) + if ((String.IsNullOrEmpty(filename) || (!File.Exists(filename)))) filename = data.DataString; return filename; }