I have not developed anything for IOS in a long time so please bear with me. Using the Swift language for the first time in XCode 6.3.
I have a pre-existing sqlite database, myDB.sqlite, that I want to import into my project.
I have added the sqlite Framework, added FMDB and the bridging header file and then added the myDB.sqlite file to my project. It is also included in "Copy Bundle Resources".
I am just trying to access myDB.sqlite in my bundle directory to copy it to my Documents directory when the app is run for the first time in the Simulator. However it keeps saying it cannot find the file.
In my AppDelegate.swift:
let dbPath = NSBundle.mainBundle().pathForResource("myDB", ofType:"sqlite")
It keeps telling me that dbPath is nil.
Check the target membership of your SQLite database and it's done:
Related
I have a sqlite database of my Qt C++ application. Suppose I located it on my default build/release folder and I also placed the database file on that same folder. I have login.h and login.cpp. I want that the application may auto detect the database and open it. I will only provide the name of database (Ex: mydb.sqlite).
Database.addDatabase("QSQLITE");
Database.setDatabaseName("I will only provide database file name here.like: mydb.sqlite");
I want that the rest of the directory should automatically detected and the database connection works perfectly.
Suppose, I have the sqlite file in:
C:/Qt/build-myapp-mingw-32/mydb.sqlite.
I am taking a string variable called path. And I want that, the application automatically detect the whole path. And open the database connection.
You do not have to give the complete path to database to make it works.
You can refer to the path from your build dir or maybe use :
QCoreApplication::applicationDirPath();
To get the path of your app and then navigate through your directories with .. ?
I m trying to put a custom path in QML file but can't get it done.
I'm trying to get de db in a shared folder where i'm willing to put the DB so any person who has the program can acces to data.
I'm using Sqlite and Qt Creator 5.7 but not a lot of info about this.
You can simply COPY the database from its default path. Typically that is located (In windows anyways) at
C:\Users\<username>AppData\Local\<program name>\QML\OfflineStorage\Databases
and on Mobile devices it is stored in a similar place --
on android its in a sub folder of:
/data/data/<Program Name>
On *nix it is located:
/home/<user>/.local/share/[ProjectName]/QML/OfflineStorage/Databases
I am using xamarin studio with xcode to create a ipad application
I have created database and table using sqlite.
Questions is, how do I view all the data I have input in the table and database.
Thanks for any answer!
SQLite Browser will help you to add/update/delete and query data in tables, and also view data.
Ideally you should save the database file in
Path.Combine (Environment.GetFolderPath(Environment.SpecialFolder.Personal), "DBName.db");
This will be at following path >
/users/[name]/Library/Application Support/iPhone Simulator/[version]/Applications/SomeNumberedApp/Documents/DBName.db
where SomeNumberedApp is a folder which will contain:
Documents folder
Application file for your app (named after your app)
Library folder
tmp folder
You would find your database in Documents folder.
SQLite Manager is a Firefox plugin that allows you to manage SQLite databases.
I can write to db when running in IDE(FB), while after packaging a air, the app wont write to sqlite db, Why? Thanks in advance.
The likely cause is that your installed Air application can't resolve the path to your sqlite file.
What I normally do is to use one of the static public properties of the File class to resolve my sqlite file from eg.
databaseConnection = new SQLConnection();
databaseConnection.addEventListener(SQLEvent.OPEN, onOpen);
databaseConnection.addEventListener(SQLErrorEvent.ERROR, onError);
databaseConnection.openAsync(File.applicationDirectory.resolvePath('mydb.sqlite'));
The key bit here is the File.applicationDirectory.resolvePath('mydb.sqlite') line, in this instance AIR will look for a file called mydb.sqlite in the directory that the application is installed into - in your development environment this would be the same as the bin-debug folder (or whatever folder you are compiling to).
Hope that helps, if not if you can post the code you are using , and what error you are getting I will try and help you further.
The most likely reason is that your DB file resides in the application directory, which is read only.
From Flex 3.5 Language Reference:
File.applicationDirectory—the read-only directory where the application is installed (along with any installed assets)
If this is the case, a possible but not only easy fix would be to just use File.applicationStorageDirectory.
Hope this helps.
N.
I am migrating a core data using sqlite as the persistentStoreCoordinator, the Core Data Model, entities, I created everything, but now my problem is I don't know how to make Core Data to write initial data file to the file I put in the mainBunddle. And there is always error like this:
-[NSKeyedUnarchiver initForReadingWithData:]: data is empty; did you forget to send -finishEncoding to the NSKeyedArchiver?
2011-07-14 17:37:59.409 SalePersonApp[1202:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSMutableArray insertObject:atIndex:]: attempt to insert nil object at 0'
when I assign my context to the appDelegate Context:
SalePersonAppAppDelegate *app = [[UIApplication sharedApplication] delegate];
NSManagedObjectContext *context = app.managedObjectContext;
Error was at the second line.
Right now my sqlite files are empty because as I told, I don't know how to make the Core Data write back my Entities to the sql file.
Can anyone tell me how to do this. Thanks so much in advance.
If you put your persistent store inside the application bundle, then it is permanently readonly because everything inside the app bundle is read only.
To make a writable store, you need to create the store in one of the app directories outside the bundle usually either in Documents or Library.
If you need to provide a pre-populated persistent store, use Core Data to populate the store when run within Xcode. Then add the persistent store file itself to the build target so that it will be written into the app bundle. The first time the app runs, copy the persistent store from the app bundle to one of the writable directories. Then open the copy as normal.