How SQLite on Android handles long strings?
Posted
by Levara
on Stack Overflow
See other posts from Stack Overflow
or by Levara
Published on 2010-06-18T08:36:48Z
Indexed on
2010/06/18
9:43 UTC
Read the original article
Hit count: 244
I'm wondering how Android's implementation of SQLite handles long Strings. Reading from online documentation on sqlite, it said that strings in sqlite are limited to 1 million characters. My strings are definitely smaller.
I'm creating a simple RSS application, and after parsing a html document, and extracting text, I'm having problem saving it to a database. I have 2 tables in database, feeds
and articles
. RSS feeds are correctly saved and retrieved from feeds
table, but when saving to the articles
table, logcat is saying that it cannot save extracted text to it's column. I don't know if other columns are making problems too, no mention of them in logcat.
I'm wondering, since text is from an article on web, are signs like (",',;) creating problems? Is Android automaticaly escaping them, or I have to do that. I'm using a technique for inserting similar to one in notepad tutorial:
public long insertArticle(long feedid, String title, String link, String description, String h1,tring h2, String h3, String p, String image, long date) {
ContentValues initialValues = new ContentValues();
initialValues.put(KEY_FEEDID, feedid);
initialValues.put(KEY_TITLE, title);
initialValues.put(KEY_LINK, link);
initialValues.put(KEY_DESCRIPTION, description );
initialValues.put(KEY_H1, h1 );
initialValues.put(KEY_H2, h2);
initialValues.put(KEY_H3, h3);
initialValues.put(KEY_P, p);
initialValues.put(KEY_IMAGE, image);
initialValues.put(KEY_DATE, date);
return mDb.insert(DATABASE_TABLE_ARTICLES,null, initialValues);
}
Column P is for extracted text, h1, h2 and h3 are for headers from a page. Logcat reports only column p to be the problem. The table is created with following statement:
private static final String DATABASE_CREATE_ARTICLES =
"create table articles( _id integer primary key autoincrement, feedid integer, title text, link text not null, description text," + "h1 text, h2 text, h3 text, p text, image text, date integer);";
© Stack Overflow or respective owner