I have an Xamarin Android (and maybe someday iOS) app that utilizes a rather sizable SQLite database (20MB+). I am somewhat new to mobile app development and definitely to Xamarin. I need to control database versioning. This is a best-practice question.
Edit/Clarification: Some of the data is app/user created or maintained. Some of the data is generated via a 3rd party and is read only, in 2nd and 3rd normal form. That data must be updated with version release. Also, the user will purchase some of these data sets in-app.
My Plan:
Everytime the app opens - OnStart (), I will validate the version of the database that is supposed to exist via a configuration string against a table value in the SQLite database with version info. If the versions don't match, the database file will be copied from the APK/assets to a local folder on the device, overwriting the existing file. I definitely don't want this to happen everytime the app opens for many reasons.
3-part question:
First, is this solution a solid approach without major road blocks? Where in Xamarin (or Android project) is best to store the database version string? And finally, is there a 3rd party library (preferably nuget) which already handles database versioning? I cannot find anything like that for .NET / Xamarin. Only some Java libraries which are more Android specific.
Related
I am working as a Xamarin forms iOS enterprise app.
We pushed config.plist (Some key-value pair) file to a real device using Mobileiron/airwatch MDM/EMM(Services). Then we deploy the Apps on iPads using MobileIron. When the app starts, the app gets Url/ credentials from config.plist that pushed by MDM.
after googling I found config.plist stored in device which in NSUserDefaults
But I am don't know is the .plist stored in NSUserDefaults with apps bundle id or something else.
Please anybody has the same issue before writing to me how I have to implements or getting value from .plist
I think you will find the details from your question on page 69-70 of Apple's MDM-Protocol-Reference. The MDM server deploys these settings using a dictionary that contains an array of bundle ids, with the settings for each app within their key. Because of how sandboxing works, your app just has to retrieve the com.apple.configuration.managed key to get its settings.
A great resource is https://www.appconfig.org/ios/
I would like to include an SQLite database in an iOS application bundle. Does MobleIron encrypt the bundle or does the developer need to encrypt the database?
I am using MobileIron AppConnect for iOS
What can be done to safeguard the database if a hacker steals a device and attempts to read the database?
If you already have the bundle and not the source code, you can only use AppConnect wrapper to add MobileIron AppConnect functionality, which doesn't include encryption capabilities.
To encrypt data at rest within the app sandbox, the developer has to include AppConnect SDK in the app. As long as the developer uses NSData Objects there is a correspond AppConnect SecureFile method available in MI AppConnect framework. Well documented in SDK documentation. Please consider that this is only possible for data/database that is created by the app on the MobileIron secured device. It is not possible to encrypt data and include it in your ipa File for distribution.
We support iOS 7, so I am not using a framework. The app is mostly objective-c, and the watchkit extension mostly in swift. The AppDelegate manages the Core Data objects.
Our app allows the user to choose a configuration to change what they see. They can switch to a different configuration. When they switch, we remove most everything from NSDefaults and we remove the sqlite database and recreate it. When they switch, its basically starting over.
On the watch side, I have a swift class that has a lazy loaded Singleton of an object that manages the core data objects. But when the app resets its data, how can we report this out to the watch extension? I am guessing that I have to reset the managed object context that the extension created.
You can use MMWormHole to send messages from your iPhone app to your WatchKit extension. In your WatchKit extension you can set the stalenessInterval for your Core Data database to something really short and you will also probably want to refresh your NSManagedObjects.
I have doubt regarding windows phone 8 application development. The database using sqlite for windows phone 8 is pre-loaded into the application or it should be created dynamically at the time of installation in windows phone..? and if it is pre-loaded then how to create the database.db file..?? and also if it is dynamically created, what is the procedure to create dynamically...??
I would say, pre-loaded into the application is the very common way.
Take a look at this article, I think the steps to accomplish your task are quite the same: http://wp.qmatteoq.com/import-an-already-existing-sqlite-database-in-a-windows-8-application/
The first step is to copy your database in to the Visual Studio project and, from the Properties window, set the Build action to Content.
Once you’ve done this operation, you’ll be able to access to the files embedded in your project thanks to the Package.Current.InstalledLocation object that is available in the Windows.ApplicationModel namespace.
The InstalledLocation’s type is StorageFolder, which is the base class of all the folders mapping in WinRT: for this reason, it exposes all the standard methods to interact with the storage, like getting a file or a folder. This way we can use the GetFileAsync method to get a reference to the database embedded into the project and, after that, using the CopyAsync method we can copy it into the local storage of the application. We can copy it in the root of the local storage (like in the following example) or in a specific folder, by getting a reference to it first using the GetFolderAsync method.
For those who are not able to work with sqlite I would like to suggest them to follow this link : http://dotnetslackers.com/articles/silverlight/Windows-Phone-7-Native-Database-Programming-via-Sqlite-Client-for-Windows-Phone.aspx and when you are dumping the data into the project .. you just need to change the properties of the "database1.sqlite" i.e. Build Action = resource . Thats all you need to do ..
I'm writing an ios app which browses(read only) a sqllite db. As the project evolves, the the db entities will change (add/modify attributes). Presumably I should get xcode to rebuild the "Managed Object class" when this happens, is that all I need to do? What about the database? How do I transition the data to the new data model?
From what I know, there is no way for you to control the structure of a Core Data database. Because CoreData gives you a lot of goodies - the visual object design and mapping - it needs to control the database's structure and content. That means that loading your own SQLite database and having CoreData manipulate it is impossible. You need to have core data load, manage, store all the data that is there. Core Data is ideal if it manages local data for the app, not when it needs to load a new database it did not create. For those instances, use either the native C layer of SQLite or a library like FMDB.