sqlite

FMDB and encryption

依然范特西╮ 提交于 2020-01-13 11:07:02
问题 I'm using FMDB to work with sqlite and I'd prefer to avoid a dependency on SQLCipher. How can I simply leverage the DataProtection capability built into iOS? Is this possible - the only requirement is to protect the data in the event of the phone being stolen. If the phone is unlocked with a PIN, it's fine that the user could access the DB - it's their data. 回答1: Look for the line where you do databaseWithPath: (or initWithPath: ), then add: FMDatabase *db = [FMDatabase databaseWithPath:path]

What happens to autoincrement primary keys after delete?

守給你的承諾、 提交于 2020-01-13 10:45:08
问题 I'm trying to create a database file with objects and sub-objects. For example, The first table would be of jars for storing change. Each jar entry would have a autoincrement primary ID key and data about the jar, like height, diameter or whatever. The second table would contain the coins. Each coin would have an ID (needed?) and would also have the ID of the jar that it is contained in and it's data (like value, year, etc.). My question is what happens to the autoincrement keys when one is

how to add column in a sqlite table in SWIFT

删除回忆录丶 提交于 2020-01-13 10:27:08
问题 I try to add a column in a table with swift. my code : connect_db(); adddbfield("mynewfield","mytable"); . func connect_db() -> Bool { let sDBPath=<is correctly set>; if sqlite3_open(sDBPath, &db) != SQLITE_OK { println("Failed to open db") return false; }else{ return true; } } . func adddbfield(sFieldName:String, sTable:String) -> Bool { var bReturn:Bool=false; var sSQL="ALTER TABLE " + sTable + " ADD COLUMN " + sFieldName + " INTEGER DEFAULT -1"; var statement:COpaquePointer = nil if

Getting null ints from sqlite in android

萝らか妹 提交于 2020-01-13 10:17:06
问题 I have an issue that may in fact be a design issue but I am struggling to find a way around it. In my sqlite database in my android application, I have a table called Customer . This has around 40 columns of various string and int data types. In practice, any of these columns may or may not be null. In my code, I have a function simply called getCustomer() , which queries the database for a specific customer, and places all their cells from the database into a Customer class, which contains

Export sqlite db in phonegap app

独自空忆成欢 提交于 2020-01-13 09:40:12
问题 We have an app using cordova (phonegap) and his own sqlite DB (I mean we didn't install an external sqlite). We need to backup the DB into the SD memory but we have problems to export the sqlite file from phonegap to SD. May anybody help us? 回答1: A couple years late, I know, but this is working for me on Cordova 5.4.1 and running on Android (I think iOS uses cordova.file.application too, but I have not tested yet): this.getdbfilename = function () { return "dbfile.db"; }; this.getdbdirectory

Find intersections between rows and timestamps in a mysql db

孤人 提交于 2020-01-13 09:36:09
问题 I have a table, where events of certain objects are listed. There are two events: "movement" and "load". They can start and end, and these events are listed with timestamps when they happened. Now i want to calculate the following three numbers: sum of time, when movement took place (value in the fiddle: 700) sum of time, when load took place (value in the fiddle: 630) sum of time, when movement and load took place (value in the fiddle: 611) I have created a sqlfiddle for the problem here:

Android: failed to setLocale() when constructing, closing the database

[亡魂溺海] 提交于 2020-01-13 09:35:10
问题 I'm trying to create a database with 12 different tables which has been working fine until today. Now every time I start my app for the first time after uninstalling it and re-installing it (or just clear app data) I get the error message seen in the title. However, the second time I start the app after getting this error it works fine. The code bellow is from my DatabaseHelper class which is more or less the same as the android notepad tutorial. This error comes after the database has been

Using ORDER BY clause inside GROUP_CONCAT function in SQLite

こ雲淡風輕ζ 提交于 2020-01-13 09:34:32
问题 I don't think that I can use ORDER BY clause inside the GROUP_CONCAT function. Does anyone know a tricky way to accomplish this behavior in SQLite ? I saw this question before. But I have a complex query . My statement looks like this: SELECT c.col1, c.col3, m.col3, m.col4, count(m.col1), count(re.col2) AS cnt, GROUP_CONCAT(p.col1 ORDER BY p.col1) AS "Group1", GROUP_CONCAT(p.col2 ORDER BY p.col1) AS "Group2", GROUP_CONCAT(CASE WHEN con.col3 is null THEN p.col1 ELSE con.col3 END), con.col4,

Selecting NULL values in Android SQLite

心不动则不痛 提交于 2020-01-13 09:24:08
问题 I'm executing the following method with no success beacause of the selectArgs being incorrect (at least this is what I believe. findAll: public Collection<Object> findAllByCodigoSetorOrderByStatusWhereDataAgendamentoIsNull(Integer vendedor) { Collection<Object> objects = null; String selection = Object.FIELDS[20] + "=?" + " OR " + Object.FIELDS[20] + "=?" + " OR " + Object.FIELDS[20] + "=?" + " AND " + Object.FIELDS[6] + "=?"; String[] selectionArgs = new String[] { "''", "'null'", "NULL",

How to Display data from SQlite into Table views to iPhone app

僤鯓⒐⒋嵵緔 提交于 2020-01-13 09:05:52
问题 I'm working on an iPhone project in Xcode 4.3 with SQlite3, the connection between the SQlite and Xcode is done, now I want to display my data into a table views (three views) and its read only! so I have the main table view, select raw --> take to 2nd view and load other data from the DB select raw --> take to the details view to display long text and image! Any help appreciated. AppDelegate.h #import "AppDelegate.h" #import "MasterViewController.h" @implementation AppDelegate @synthesize