Tag: sqlite

如何将文件从主包复制到文件夹

我想检查Document文件夹中的一个文件。如果此文件不存在于文档文件夹中,则需要将其从主包复制到文档文件夹。 我写这个代码和这个文件是复制,但我的问题在这里….. !!!! 我的文件是.sqlite文件(数据库文件),当复制到文档文件夹没有自己的数据! 为什么??? 而这个文件在主包中有自己的数据。 这是我的代码,但我不知道为什么不工作! #define DataName @"mydatabase.sqlite" – (void)viewDidLoad { [self CopyDatabase]; [super viewDidLoad]; // Do any additional setup after loading the view from its nib. } – (NSString*)DatabasePath { NSArray *Paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *DocumentDir = [Paths objectAtIndex:0]; //NSLog(@"%@",DocumentDir); return [DocumentDir stringByAppendingPathComponent:DataName]; } – (void)CopyDatabase { BOOL success; NSFileManager […]

使用FMDB将数据从sqlite显示到标签

如何显示来自SQLite的数据使用FMDB标签,如下所示: 我想显示任何输出是以这种格式供用户看到。 没有互动。 只显示select查询。

Xamarin.iOS中的自定义SQLite函数

我正在Xamarin.iOS上处理Sqlite的自定义函数。 我从这里得到的答案: 在给定的半径(Xamarin.Android)在地图上显示标记,但我遇到了问题 尝试使用–aot-only运行时JIT编译方法'(包装本机到托pipe)Mono.Data.Sqlite.SqliteFunction:ScalarCallback(intptr,int,intptr)'。 在栈上search后,我发现这里是一个解决scheme: 自定义函数SQLite与单声道,但解决scheme提到有我很难理解。 我不知道如何使用MonoPInvokeCallbackAttribute注释方法,并将其设置为静态,因为SqliteFunction类中的方法被覆盖,所以不能使其为静态。 如果有人能够帮助我理解该解决scheme或提供解决scheme中缺less的步骤,那将是非常好的。

如何在iphone中的sqlite数据库中存储图像?

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingPathComponent:@"image.sqlite"]; if (sqlite3_open_v2([path UTF8String], &database, SQLITE_OPEN_READWRITE, NULL) == SQLITE_OK) { if(selectStmt == nil) { const char *sql = "insert into imagetb(imagename,image) Values(?,?)"; if(sqlite3_prepare_v2(database, sql, -1, &selectStmt, NULL) != SQLITE_OK) // NSAssert1(0, @"Error while creating add statement. '%s'", sqlite3_errmsg(database)); NSLog(@"%s",sqlite3_errmsg(database)); } […]

核心数据与SQLite

我正在写一个琐事程序,其中将有数百个问题集。 该应用程序将预先加载一些测验,但他们需要下载进一步的测验,一旦下载将存储在应用程序,以便用户可以离线播放它们。 在这个特定的例子中,我会更好地使用核心数据或SQLite。 提前致谢。

如何使用sqlite文件将数据预加载到iOS应用程序中

在新的Xcode 5版本之前,我可以通过引用项目中的文件将数据预加载到我的核心数据驱动的应用程序中。 但是,自升级我的XCode以来,我的JSON数据现在被保存到3个文件中: 一个空的.sqlite文件 一个.sqlite-wal文件 一个.sqlite-shm文件。 我如何将这些数据导入到我的应用程序? 在过去,我只需要复制sqlite文件,我就完成了。 现在,我不知道我应该复制什么文件。

在iOS中同步压缩的sqlite数据库可能会导致应用程序被拒绝

我有一个SQLite数据库,我需要使用iCloud进行备份。 我知道,苹果build议不要同步整个数据库,它可能会拒绝该应用程序 。 可能的解决方法包括 – 1) 切换到核心数据 – 对于这个选项来说太晚了,给了核心数据的学习曲线,我不想延长时间表。 2) 维护日志文件的SQLite和同步日志文件 – 这个选项是更有效的,我会作为一个故障安全 3) 使用ZipArchive压缩数据库并同步压缩文件 – 这将是最容易实现的,但我不确定苹果是否拒绝或接受这一点。 Zip之前的大小是300kb,zip之后大约是40kb。 有没有其他人试过压缩的方法,并成功地提交了他们的应用程序到appstore? 任何其他build议将是非常有用的。 谢谢

sqlite 3开放问题

我从sqlite3文件中获取我的数据,有几个类似的方法,如下面的代码所示: -(NSMutableArray *) getCountersByID:(NSString *) championID{ NSMutableArray *arrayOfCounters; arrayOfCounters = [[NSMutableArray alloc] init]; @try { NSFileManager *fileManager = [NSFileManager defaultManager]; NSString *databasePath = [[[NSBundle mainBundle] resourcePath ]stringByAppendingPathComponent:@"DatabaseCounters.sqlite"]; BOOL success = [fileManager fileExistsAtPath:databasePath]; if (!success) { NSLog(@"cannot connect to Database! at filepath %@",databasePath); } else{ NSLog (@"SUCCESS getCountersByID!!"); } if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK){ NSString *tempString […]

Sqlite查询,比较date时间字段与当前的date时间

在我的iPhone应用程序,我想查询过去的logging。 有一个名为“task_dateTime”的date时间字段。 如果使用,从任务中selecttask_dateTime; 结果看起来像这样,2012年4月26日16:32 2012年4月27日16:38 2012年4月29日05:32 我如何查询以前的logging。 这意味着我想用当前时间与“task_dateTime”字段进行比较。

不能将数据添加到本地DB sqlite IOS

这是我的代码: 为了创build数据库,在我的ViewDidLoad中: NSString *docsDir; NSArray *dirPaths; dirPaths=NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES); docsDir = [dirPaths objectAtIndex:0]; databasePath = [[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent: @"contacts.db"]]; NSFileManager *filemgr=[NSFileManager defaultManager]; if ([filemgr fileExistsAtPath:databasePath]==NO) { NSLog(@"Creating DB"); const char *dbpath=[databasePath UTF8String]; if (sqlite3_open(dbpath, &contactDB)==SQLITE_OK) { char *error_msg; const char *sql_stmt = "CREATE TABLE IF NOT EXISTS CONTACTS (ID INTEGER PRIMARY KEY AUTOINCREMENT, […]