Hi all.
In my application I've added some functionality to backup and restore
a database. To prevent overwriting of the existing database with a file
that isn't a database at all, I'm doing a quick and dirty check
like this:
Essentially this code tries to open the file, checks if there is an ID column
and if not, the file is considered invalid.
So far so good! The bad thing is, if it's not a database file like
in the code above (test.html), the file gets deleted! I guess this should not
happen, should it?
regards,
obscure
In my application I've added some functionality to backup and restore
a database. To prevent overwriting of the existing database with a file
that isn't a database at all, I'm doing a quick and dirty check
like this:
B4X:
Dim localDB As SQL
Dim localCursor As Cursor
Dim isValid As Boolean=True
Try
localDB.Initialize(File.DirDefaultExternal, "test.html", False)
localCursor = localDB.ExecQuery("SELECT ID FROM table1")
localCursor.Close
Catch
isValid=False
End Try
Essentially this code tries to open the file, checks if there is an ID column
and if not, the file is considered invalid.
So far so good! The bad thing is, if it's not a database file like
in the code above (test.html), the file gets deleted! I guess this should not
happen, should it?
regards,
obscure