Posts

Showing posts with the label Sqlite

Convert NSData To String?

Answer : Objective-C You can use (see NSString Class Reference) - (id)initWithData:(NSData *)data encoding:(NSStringEncoding)encoding Example: NSString *myString = [[NSString alloc] initWithData:myData encoding:NSUTF8StringEncoding]; Remark : Please notice the NSData value must be valid for the encoding specified (UTF-8 in the example above), otherwise nil will be returned: Returns nil if the initialization fails for some reason (for example if data does not represent valid data for encoding). Prior Swift 3.0 String(data: yourData, encoding: NSUTF8StringEncoding) Swift 3.0 Onwards String(data: yourData, encoding: .utf8) See String#init(data:encoding:) Reference Prior Swift 3.0 : String(data: yourData, encoding: NSUTF8StringEncoding) For Swift 4.0: String(data: yourData, encoding: .utf8) I believe your "P" as the dataWithBytes param NSData *keydata = [NSData dataWithBytes:P length:len]; should be "buf" NSData *keydata = [NSData dataWithBytes:buf length:len]; sin...

Android SQLite Auto Increment

Answer : Make it INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL . Here's what the docs say: If a column has the type INTEGER PRIMARY KEY AUTOINCREMENT then... the ROWID chosen for the new row is at least one larger than the largest ROWID that has ever before existed in that same table. The behavior implemented by the AUTOINCREMENT keyword is subtly different from the default behavior. With AUTOINCREMENT, rows with automatically selected ROWIDs are guaranteed to have ROWIDs that have never been used before by the same table in the same database. And the automatically generated ROWIDs are guaranteed to be monotonically increasing. SQLite AUTOINCREMENT is a keyword used for auto incrementing a value of a field in the table. We can auto increment a field value by using AUTOINCREMENT keyword when creating a table with specific column name to auto incrementing it. The keyword AUTOINCREMENT can be used with INTEGER field only. Syntax: The basic usage of AU...