sqlite

How to compile sqlite with ICU?

心已入冬 提交于 2020-01-21 04:51:13
问题 I downloaded sqlite from http://www.sqlite.org/sqlite-autoconf-3070701.tar.gz How can I compile sqlite with icu ? 回答1: 1) You can compile it as dynamic extension of SQLite Citing http://www.sqlite.org/cvstrac/fileview?f=sqlite/ext/icu/README.txt The easiest way to compile and use the ICU extension is to build and use it as a dynamically loadable SQLite extension. To do this using gcc on *nix: gcc -shared icu.c `icu-config --cppflags --ldflags` -o libSqliteIcu.so You may need to add "-I" flags

RealmObject AND Parcelable

时光总嘲笑我的痴心妄想 提交于 2020-01-21 04:34:12
问题 I'm new to Realm for Android so I'm not sure I'm approaching this the right way. I have a class which looks like this: public class Entry extends RealmObject implements Parcelable { ... } The problem is the Parcelable interface contains methods like describeContents() writeToParcel() and RealmObjects aren't supposed to have methods other than getters and setters: Error:(81, 17) error: Only getters and setters should be defined in model classes So my question is: How can I make these two work

RealmObject AND Parcelable

半世苍凉 提交于 2020-01-21 04:34:07
问题 I'm new to Realm for Android so I'm not sure I'm approaching this the right way. I have a class which looks like this: public class Entry extends RealmObject implements Parcelable { ... } The problem is the Parcelable interface contains methods like describeContents() writeToParcel() and RealmObjects aren't supposed to have methods other than getters and setters: Error:(81, 17) error: Only getters and setters should be defined in model classes So my question is: How can I make these two work

DISTINCT clause in SQLite

吃可爱长大的小学妹 提交于 2020-01-21 03:16:27
问题 Recently i found that SQLite don't support DISTINCT ON() clause that seems postgresql-specific. For exeample, if i have table t with columns a and b . And i want to select all items with distinct b . Is the following query the only one and correct way to do so in SQLite? select * from t where b in (select distinct b from t) Sample data: a | b __|__ 1 5 2 5 3 6 4 6 What i expect in return: a | b __|__ 1 5 3 6 回答1: Use: SELECT MIN(t.a) AS A, t.b FROM TABLE t GROUP BY t.b 回答2: sqlite> SELECT *

How to create a table with a two or more foreign keys using Android Room?

懵懂的女人 提交于 2020-01-21 03:14:49
问题 According the entity-relationship model, the relationship between tbl_post and tbl_category could be specified using Room Persistency Library as follows: @Entity(foreignKeys = @ForeignKey( entity = TblPost.class, parentColumns = "id", childColumns = "tbl_post_id") ) class TblPostCategory { @PrimaryKey public String id; @ColumnInfo(name = "user_id") public String postId; } However TblPostCategory depends on two foreign keys: post_id and category_id from TblPost and TbCategory . How the

How to create a table with a two or more foreign keys using Android Room?

你离开我真会死。 提交于 2020-01-21 03:14:05
问题 According the entity-relationship model, the relationship between tbl_post and tbl_category could be specified using Room Persistency Library as follows: @Entity(foreignKeys = @ForeignKey( entity = TblPost.class, parentColumns = "id", childColumns = "tbl_post_id") ) class TblPostCategory { @PrimaryKey public String id; @ColumnInfo(name = "user_id") public String postId; } However TblPostCategory depends on two foreign keys: post_id and category_id from TblPost and TbCategory . How the

SQLite3

时光毁灭记忆、已成空白 提交于 2020-01-21 03:03:48
SQLite3 创建db文件 sqlite database_name.db 导出 sqlite database_name.db > test.sql 恢复 sqlite database_name.db < test.sql 退出命令 .quit 查看当前数据库 .databases 附加数据库 如果数据库未尚未创建,创建数据,如果如果数据库已存在,则把数据库文件名称与逻辑数据库 ‘Alias-Name’ 绑定在一起。 # ATTACH DATABASE file_name AS database_name; attach database 'test.db' as 'TEST'; 分离数据库 无法分离main和temp # 查看数据库列表 sqlite> .databases main: C:\Code\SQLite\test.db TEST: C:\Code\SQLite\test.db # 分享数据库 sqlite> DETACH DATABASE 'TEST'; # 查看数据库列表 sqlite> .database main: C:\Code\SQLite\test.db 参考 菜鸟教程SQLite 来源: CSDN 作者: yimt 链接: https://blog.csdn.net/YIMT_F/article/details/104049513

How to set default value to empty string for TEXT column?

久未见 提交于 2020-01-21 01:35:30
问题 I am using SQLite Manager. I have a column named "MainContactName" and its structure is TEXT NOT NULL=0 By default, every row in the column has a "red background" meaning it is NULL . How can I make this have a "green background" and be empty string? 回答1: You can specify a default value for the column when you create the table. (It doesn't appear as though you can add a default using an ALTER statement, so you'll have to recreate your table.) CREATE TABLE your_table_name (MainContactName TEXT

【UWP】使用 LiteDB 存储数据

廉价感情. 提交于 2020-01-20 18:34:05
序言: 在 UWP 中,常见的存储数据方式基本上就两种。第一种方案是 UWP 框架提供的 ApplicationData Settings 这一系列的方法,适用于存放比较轻量的数据,例如存个 Boolean 类型的设置项这种是最适合不过的了。另一种方案是用 Sqlite 这种 数据库 ,适合存放数据量大或者结构复杂,又或者需要根据条件查询的场合,例如开发个宝可梦数据查询,或者 Jav 图书馆(咳咳)。 场景分析: 在某些场合,我们很可能是要持久化一个复杂的对象的,例如通过 OAuth 授权成功获取到的用户信息,有可能就类似下面的结构: { "id": 1 , "name": "Justin Liu" , "gender": 2 , "location" : { "name": "Melbourne" , "name_cn": "墨尔本" } } 又或者做一个 RSS 阅读器,弄个后台服务提前先把数据拉下来,那肯定也要存放起来吧。这相当于要把一个以时间排序为依据的列表进行持久化。 ApplicationData Settings 方案 在以上两种场合,用 ApplicationData Settings 解决起来可能是比较快速的。以第一种情况来说,又可以细分两种存储方案。 A 方案,分字段存放: ApplicationData.Current.LocalSettings.Values

Sqlite database not copied from asset folder Android

北慕城南 提交于 2020-01-20 08:37:16
问题 I am trying to copy a database named "adinpect" from the asset folder to the application databases folder, but it is not working... Code (in main activity onCreate(), just for testing): try { String destPath = "/data/data/" + getPackageName() + "/databases"; File f = new File(destPath); if (!f.exists()) { f.mkdirs(); f.createNewFile(); //---copy the db from the assets folder into the databases folder--- CopyDB(getBaseContext().getAssets().open("adinspect"), new FileOutputStream(destPath + "