Creating a database in the blackberry device when the app is installed - sqlite

I want to create a database on my blackberry device when my app is installed. I did not find any event (e.g. onInstalled) so that i can create my databse on this event when the app is installed.
Apparently there is a method DatabaseFactory.exists() which i can use to check if the database exists or not. But i do not want to check for this every time. I want to create the database when my app is installed and when the app is un-installed then the database should also get deleted.
Thanks

As far as I know RIM API SDK does not provide mechanism to catch install/uninstall events.
And even the database is once created it can be deleted/damaged via the filesystem. For instance user deletes database files from the media-card or from the device memory. Just because user does not know what these files contain and assumes these as temporary or something else.
It is a good approach to check the database presence before starting work with it. Otherwise user may get blank white screen with text "Exception 1234" and some additional text, or may get a popup with strange message, like "Error: FileNotFoundException...".

See the SQLiteDemo in the blackberry samples demo then you can get solution.

Related

Xamarin Forms how to Save a file to a location where it can be copied off of the original device

My Xamarin forms app required the user to perform a certain amount of configuration before it can be used. Additionally, the app can be run on multiple computers by the same user (There are valid business reasons for doing this.) What I would like to be able to do is backup the configuration of the app to a file that can then be used on another device to automatically configure the app on the new device in exactly the same way. This will prevent the users from re-entering all the configuration information on each device where they wish to run the app.
Something to keep in mind:
It needs to work on all supported Xamarin Forms platforms - UWP, Android, iOS and Mac.
The app itself does not required the device to have a network connection.
The file needs to be savable in a place where the user can access / copy it to another device (i.e. a USB drive, a network share etc.)
What I have tried:
I have tried using the FilePicker plug in but could not get it to save to anywhere outside the application. (A user trying to find the folder here would not be easy.) Saving anyplace else I received an Access Denied error.
I have tried using the System.IO namespace but encountered the same Access Denied error when saving the file to a someplace outside the application.
I guess my last resort would be to display the configuration information in a XF editor control or such or just copy it to the clipboard (if possible) and have the user manually save the data to a file outside of the application. Does anyone have any other suggestions on how this can be handled?
So after trying multiple things and looking at possible solutions, I could not find a way to easily do this. Instead I used the Xamarin Essentials clipboard function and copied the contents of the file into the clipboard. I then display a message to the user telling them to past the clipboard contents into a file. This seemed to be the best I could do for now.

Image picker view not crashing not even asking for user permission, Why and How?

I am working on one side project, it has image view where a user can click and select an image from the photo library. I am using UIImagePickerController.
My question is I haven't added user Permission on plist nor anywhere else. and as far I know app crashed if you don't add permission, Plus when the app opens for the first time the dialog appears asking for permission but in my case, it's not asking.
I like to know how this can be possible or does Apple have changed something in new Xcode or OS?
I am using Version 9.2 (9C40b) and tried running the code on iPhone 6(real device iOS 11.2.6,) and in different simulator same result, I deleted the app and run it again, same no dialog.
And if Apple has changed something in iOS 11, Should we add or not the permission? whats the best way to a developer we don't want to ask, and also don't want the app to be crashed.
The answer is YES you have to provide the description
It is mandatory to add usage description(from iOS 11) of permissions you are going to use.
Apple states that
Your app is responsible for all usage of privacy-sensitive data, including access to this data by all third-party libraries used in your app. If your app attempts to access privacy-sensitive data without a usage description, your app will exit.
You will see this error in console log if permission description is not provided in Info.plist
This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.
If you try to submit the app without description for release Apple will reject it with this message
Missing Info.plist key - This app attempts to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSSpeechRecognitionUsageDescription key with a string value explaining to the user how the app uses this data.
Summary:
If you have not provided usage description and uploaded the app earlier then your app will crash without asking for permission
If you have not provided usage description and tried to submit recently then apple will reject it.
Reference:
Privacy Settings in iOS 10

How to persist SQLite database on Icenium?

I try to build a database on Icenium with SQLite and the db does not persist - why? I think the structure of the database is not built on a physical level. Someone you ever had this problem?
I was able to use SQLite with Icenium on my project successfully. As I see, there is also an example that you can look up:
https://github.com/Icenium/sample-sqlite.git
You might also want to take a look at this post: Creating a Database from a SQL Dump, for using prepopulated SQLite database.
From my experience with Telerik AppBuilder (formerly called Icenium), each time you Run the project in a simulator, the simulator starts from scratch and it keeps no record of what happened in previous runs.
The solution I would use to 'persist' the database on a session basis and test your code is as below.
You must keep the simulator open (so don't close it) to keep database intact
and just press Reload button in simulator window to see how an existing database
would run on a real device every time the app is re-started on a real device,
because within a single Run of the simulator it remembers everything.
Even if you want to make changes to your code or html, leave the simulator open and make your code changes (and Save), and then click on Refresh button in simulator window to bring in your recent code changes without losing the database and its data. If you follow this approach you can easily test how a database would behave on real device where a database is naturally persisted.
So think, in terms of 'simulator session' when developing hybrid apps using Telerik AppBuilder.

how to use pre-populated database with tidesdk/titanium desktop

I'm in need of some help in developing a desktop application with a pre-populated database. I have tried numerous ways to get this working including those mentioned on both Tidesdk's API here http://tidesdk.multipart.net/docs/user-dev/generated/#!/api/Ti.Database.DB and at Titanium Desktops old API here http://developer.appcelerator.com/apidoc/desktop/latest/Titanium.Database-module.
While the later (using Titanium not Ti) works in creating a database in the apps directory it does not install my pre-populated sqlite database which is located in the resources file of my app.
A couple of my attempts located below
var db = Titanium.Database.openFile('test_db.sqlite', 'test_db');
var db = Titanium.Database.openFile(Ti.Filesystem.getFile(
Ti.Filesystem.getApplicationDataDirectory(), 'test_db.sqlite'));
var db = Ti.Database.open('test_db');
As stated most of these manage to create a database with the name given but when trying to run something as simple as a db.execute(SELECT) of something I know would exist in my pre-populated db I receive an error stating
Exception executing: SELECT name, id FROM people ORDER BY name COLLATE NOCASE, Error was: SQL Statement invalid or database missing
I have searched high and low for something to answer this but everyone continues to refer to the aforementioned API's or to the Mobile API's Ti.database.install() which does not work either.
Is it possible with titanium desktop to use a pre-populated sqlite database or do I have to populate it after I create it? If so any direction would be helpful (where to place the .sqlite file in the app and what functions to call).
I am currently using Titanium Studio with a titanium desktop osx SDK of 1.2.0.RC4 as requested by tidesdk.org until they have released there open source sdk.
Thanks in advance
This is possible, I just used this feature in a recent desktop app, deployed it successfully to Windows and Mac.
In my experience, sometimes your database file can be corrupted, for example if you use the Titanium.Database.install command, and it cant find the file to preload from (maybe the first time you specified the path wrong for instance), it will create the file itself, any subsequent install commands will not work because it already thinks this database has been installed.
Have you tried clearing out the application data? This is where titanium installs the database. For Mac this is in your /User/Library/Application Support/APPNAME directory. Their is a directory for databases, delete this and try again.
Also, this answer on Titanium Q&A may help, it talks about the process with the Mobile SDK but the Database stuff is the same.
Hope this helps!

Phonegap : What happens to my sqlite database?

I am using phonegap for my mobile application. I am creating a database from the application.
Everything is working fine and as expected.
But what happens to my database when I uninstall my application?
The database is also removed or do I have to remove the database manually?
I have created a different app to erase the database, but looking at the console.log()s it is seen that database also gets erased along with the application.
Is it true? or am I doing something wrong?
In my experience, when you deinstall the App like the user would by deleting the App on the Telephone, the Data of Database also gets deleted.
When I re-install the App for Developing, let`s say with
./adb install <packagename>
or from XCode, the Data does not get deleted.

Resources