SQLite语法错误,但仅限于三星Galaxy Tab

时间:2014-01-03 14:20:00

标签: android sqlite samsung-mobile

我有一个奇怪的问题,似乎是特定于设备的:我的Android播客播放器应用程序从服务器获取数据并将其插入数据库。对于超过100个用户,一切正常。但是对于一个用户而言,数据插入失败并出现SQLite语法错误,但仅在他的Galaxy Tab(GT-P7310)上安装了Android 4.0.4。同一个用户还有两部手机(Galaxy Nexus和Nexus 5),相同的数据可以正常工作。

我可以在本地SQLite安装中执行语句而不会出现问题。

这是导致问题的声明,添加了几个换行符以使其更具可读性:

INSERT OR REPLACE INTO podcast
(uid, uri, url, title, subTitle, link, authorName, authorEmail, categories, keywords, description, imageUrl, modified, subscribed, settings_autoAddEpisodes, settings_autoDownload, settings_maxKeptEpisodes, settings_playbackSpeed, id)
VALUES
(19, 'http://api.sr.se/api/rss/pod/17155', 'http://api.sr.se/api/rss/pod/17155', 'Luuk & Lokko', NULL, 'http://sverigesradio.se/sida/default.aspx?programid=4296', 'Luuk & Lokko', 'podd@sverigesradio.se', '[{"name":"Society \u0026 Culture"}]', '[]', 'Luuk & Lokko är ett schemalagt veckosamtal där Kristian Luuk och Andres Lokko pratar med varandra om ämnen som de har bestämt på förhand. Vissa infall kan förekomma men de kommer att vara ytterst tyglade samt relativt få.', 'http://sverigesradio.se/diverse/appdata/isidor/images/news_images/4296/2143980_512_512.jpg', 1386174193000, 1, 0, 0, NULL, NULL, NULL),
(580, 'http://sverigesradio.se/api/rss/pod/18535', 'http://sverigesradio.se/api/rss/pod/18535', 'FotbollsArena Radiosporten', NULL, 'http://sverigesradio.se/sida/default.aspx?programid=4410', 'FotbollsArena Radiosporten', 'podd@sverigesradio.se', '[{"name":"Sports \u0026 Recreation"}]', '[]', 'Varje vecka diskuterar Radiosportens Richard Henriksson med gäster det senaste och hetaste i fotbollsvärlden. Allt från allsvenskan och landslaget till de stora ligorna i Europa.', 'http://sverigesradio.se/diverse/appdata/isidor/images/news_images/4410/2708666_512_512.jpg', 1386173280000, 1, 0, 0, NULL, NULL, NULL),
(581, 'http://sverigesradio.se/api/rss/pod/18656', 'http://sverigesradio.se/api/rss/pod/18656', 'Musikguiden i P3 ', NULL, 'http://sverigesradio.se/sida/default.aspx?programid=4067', 'Musikguiden i P3', 'podd@sverigesradio.se', '[{"name":"Music"}]', '[]', ': Jenny Seth presenterar Musikguiden i P3s journalistiska magasin. Vi går på djupet i musik från alla genres genom intervjuer, reportage och gäster i studion.', 'http://sverigesradio.se/diverse/appdata/isidor/images/news_images/4067/2472633_512_512.jpg', 1386173083000, 1, 0, 0, NULL, NULL, NULL),
(796, 'http://www.stonesthrow.com/jukebox/podcast.xml', 'http://www.stonesthrow.com/jukebox/podcast.xml', 'Stones Throw Podcast', NULL, 'http://www.stonesthrow.com/podcast', 'Stones Throw Records', 'losangeles@stonesthrow.com', '[{"name":"Music"}]', '[]', 'Music from Stones Throw and the Stones Throw DJs. Archive available at stonesthrow.com', 'http://www.stonesthrow.com/images/stonesthrowpodcast.jpg', 1381769169000, 1, 0, 0, NULL, NULL, NULL),
(1174, 'http://swedroid.libsyn.com/rss', 'http://swedroid.libsyn.com/rss', 'Swedroid Podcast', '', 'http://www.swedroid.se', 'Swedroid', 'podcast@swedroid.se', '[{"name":"Technology","subCategory":"Gadgets"},{"name":"Technology","subCategory":"Podcasting"},{"name":"Technology","subCategory":"Tech News"}]', '["android","podcast","smartphone","swedroid"]', 'Intresserad av Android, Google och smarta telefoner? Missa inte Swedroids podcast! Vi går varje vecka igenom det senaste på Androidfronten.', 'http://assets.libsyn.com/content/6515469.jpg', 1386609291000, 1, 0, 0, NULL, NULL, NULL),
(247, 'http://feeds.feedburner.com/filipochfredrik/podcast', 'http://feeds.feedburner.com/filipochfredrik/podcast', 'Filip och Fredriks podcast', 'Filip & Fredrik och en mikrofon, en gång i veckan. Utnämnd till Sveriges bästa podcast 2011 (Svenska podradiopriset).', 'http://www.filipochfredrik.com', 'Filip och Fredrik', 'podcast@filipochfredrik.com', '[{"name":"Comedy"}]', '[]', 'Filip & Fredrik och en mikrofon, en gång i veckan. Utnämnd till Sveriges bästa podcast 2011 (Svenska podradiopriset).', 'http://www.filipochfredrik.com/wp-content/themes/filipochfredrik/images/ff-podcast-600x600.jpg', 1382878323000, 1, 0, 0, NULL, NULL, NULL),
(6, 'http://alexosigge.libsyn.com/rss', 'http://alexosigge.libsyn.com/rss', 'Alex & Sigges podcast', '', 'http://alexosigge.libsyn.com', 'Alex Schulman & Sigge Eklund', 'alexochsigge@gmail.com', '[{"name":"Comedy"}]', '["schulmans","podcast","eklund","sigge","sigges","schulman","eklunds","alex","radio","podradio"]', 'Alex Schulmans och Sigge Eklunds podcast som publiceras en gång i veckan.', 'http://assets.libsyn.com/content/4601369.jpg', 1386022416000, 1, 0, 0, NULL, NULL, NULL),
(73, 'http://computersweden.libsyn.com/rss', 'http://computersweden.libsyn.com/rss', 'Computer Swedens podcast', 'CS ger dig koll på veckans viktigaste it-händelser', 'http://computersweden.libsyn.com', 'Bjorn Olsberg', 'bjorn.olsberg@idg.se', '[{"name":"Technology","subCategory":"Podcasting"},{"name":"News \u0026 Politics"},{"name":"Technology","subCategory":"Tech News"}]', '["computer","cs","sweden"]', 'Lyssna i stället för att läsa! I Computer Swedens podcast sammanfattar vi it-nyheterna den senaste veckan, med fokus på de tre ämnen som vi tycker är intressantast att diskutera. Nyhetschef Sverker Brundin, debattredaktör Eva Melin och teknikreporter Tomas Zirn blandar hårt med mjukt och högt med lågt varje torsdag kl 17.00.', 'http://assets.libsyn.com/content/6406700.jpg', 1386023131000, 1, 0, 0, NULL, NULL, NULL),
(212, 'http://feeds.feedburner.com/ThisIsMyNextPodcast', 'http://feeds.feedburner.com/ThisIsMyNextPodcast', 'The Vergecast', 'The Vergecast', 'http://www.theverge.com/verge/verge_archives/show?mode=EntryGroup&slug=the-vergecast', 'Joshua Topolsky, Nilay Patel, Paul Miller', 'joshua@theverge.com', '[{"name":"Technology","subCategory":"Tech News"},{"name":"Technology","subCategory":"Gadgets"},{"name":"Technology"}]', '["joshua","gadgets","pcs","this","mac","smartphones","technology","miller","next","apple","pc","gadget","google","laptops","macs","is","paul","tech","ipad","patel","news","nilay","iphone","windows","android","timp","osx","podcast","my","topolsky","microsoft","tablet","tabelts"]', 'The Vergecast is your source for an irreverent and informative look at what''s happening right now (and next) in the world of technology and gadgets. Hosted by Joshua Topolsky, Nilay Patel, and Paul Miller alongside a cavalcade of tech luminaries, The Vergecast is the only podcast you need to make sense of the week in tech news. And your life.', 'http://assets.sbnation.com/assets/770431/vergecast.png', 1382873693000, 1, 0, 0, NULL, NULL, NULL),
(173, 'http://feeds.feedburner.com/Iterate', 'http://feeds.feedburner.com/Iterate', 'Iterate', 'Iterate: Loop until done.', 'http://www.iterate.tv/', 'Edwards, Clifford, Ritchie', 'rene@mobilenations.com', '[{"name":"Arts","subCategory":"Design"},{"name":"Technology","subCategory":"Software How-To"}]', '["icons","windows","interface","design","ipad","x","ux","blackberry","ui","webos","user","phone","iphone","mac","android","experience","os"]', 'Iterate brings together the best designers and app producers in the business to talk user interface and user experience from concept to implementation. Hosted by Marc Edwards, Seth Clifford, and Rene Ritchie. Loop until done.', 'http://www.mobilenations.com/broadcasting/podcast_iterate_1400.jpg', 1382885371000, 1, 0, 0, NULL, NULL, NULL)

这里是一行中的原始陈述

INSERT OR REPLACE INTO podcast (uid, uri, url, title, subTitle, link, authorName, authorEmail, categories, keywords, description, imageUrl, modified, subscribed, settings_autoAddEpisodes, settings_autoDownload, settings_maxKeptEpisodes, settings_playbackSpeed, id) VALUES (19, 'http://api.sr.se/api/rss/pod/17155', 'http://api.sr.se/api/rss/pod/17155', 'Luuk & Lokko', NULL, 'http://sverigesradio.se/sida/default.aspx?programid=4296', 'Luuk & Lokko', 'podd@sverigesradio.se', '[{"name":"Society \u0026 Culture"}]', '[]', 'Luuk & Lokko är ett schemalagt veckosamtal där Kristian Luuk och Andres Lokko pratar med varandra om ämnen som de har bestämt på förhand. Vissa infall kan förekomma men de kommer att vara ytterst tyglade samt relativt få.', 'http://sverigesradio.se/diverse/appdata/isidor/images/news_images/4296/2143980_512_512.jpg', 1386174193000, 1, 0, 0, NULL, NULL, NULL), (580, 'http://sverigesradio.se/api/rss/pod/18535', 'http://sverigesradio.se/api/rss/pod/18535', 'FotbollsArena Radiosporten', NULL, 'http://sverigesradio.se/sida/default.aspx?programid=4410', 'FotbollsArena Radiosporten', 'podd@sverigesradio.se', '[{"name":"Sports \u0026 Recreation"}]', '[]', 'Varje vecka diskuterar Radiosportens Richard Henriksson med gäster det senaste och hetaste i fotbollsvärlden. Allt från allsvenskan och landslaget till de stora ligorna i Europa.', 'http://sverigesradio.se/diverse/appdata/isidor/images/news_images/4410/2708666_512_512.jpg', 1386173280000, 1, 0, 0, NULL, NULL, NULL), (581, 'http://sverigesradio.se/api/rss/pod/18656', 'http://sverigesradio.se/api/rss/pod/18656', 'Musikguiden i P3 ', NULL, 'http://sverigesradio.se/sida/default.aspx?programid=4067', 'Musikguiden i P3', 'podd@sverigesradio.se', '[{"name":"Music"}]', '[]', ': Jenny Seth presenterar Musikguiden i P3s journalistiska magasin. Vi går på djupet i musik från alla genres genom intervjuer, reportage och gäster i studion.', 'http://sverigesradio.se/diverse/appdata/isidor/images/news_images/4067/2472633_512_512.jpg', 1386173083000, 1, 0, 0, NULL, NULL, NULL), (796, 'http://www.stonesthrow.com/jukebox/podcast.xml', 'http://www.stonesthrow.com/jukebox/podcast.xml', 'Stones Throw Podcast', NULL, 'http://www.stonesthrow.com/podcast', 'Stones Throw Records', 'losangeles@stonesthrow.com', '[{"name":"Music"}]', '[]', 'Music from Stones Throw and the Stones Throw DJs. Archive available at stonesthrow.com', 'http://www.stonesthrow.com/images/stonesthrowpodcast.jpg', 1381769169000, 1, 0, 0, NULL, NULL, NULL), (1174, 'http://swedroid.libsyn.com/rss', 'http://swedroid.libsyn.com/rss', 'Swedroid Podcast', '', 'http://www.swedroid.se', 'Swedroid', 'podcast@swedroid.se', '[{"name":"Technology","subCategory":"Gadgets"},{"name":"Technology","subCategory":"Podcasting"},{"name":"Technology","subCategory":"Tech News"}]', '["android","podcast","smartphone","swedroid"]', 'Intresserad av Android, Google och smarta telefoner? Missa inte Swedroids podcast! Vi går varje vecka igenom det senaste på Androidfronten.', 'http://assets.libsyn.com/content/6515469.jpg', 1386609291000, 1, 0, 0, NULL, NULL, NULL), (247, 'http://feeds.feedburner.com/filipochfredrik/podcast', 'http://feeds.feedburner.com/filipochfredrik/podcast', 'Filip och Fredriks podcast', 'Filip & Fredrik och en mikrofon, en gång i veckan. Utnämnd till Sveriges bästa podcast 2011 (Svenska podradiopriset).', 'http://www.filipochfredrik.com', 'Filip och Fredrik', 'podcast@filipochfredrik.com', '[{"name":"Comedy"}]', '[]', 'Filip & Fredrik och en mikrofon, en gång i veckan. Utnämnd till Sveriges bästa podcast 2011 (Svenska podradiopriset).', 'http://www.filipochfredrik.com/wp-content/themes/filipochfredrik/images/ff-podcast-600x600.jpg', 1382878323000, 1, 0, 0, NULL, NULL, NULL), (6, 'http://alexosigge.libsyn.com/rss', 'http://alexosigge.libsyn.com/rss', 'Alex & Sigges podcast', '', 'http://alexosigge.libsyn.com', 'Alex Schulman & Sigge Eklund', 'alexochsigge@gmail.com', '[{"name":"Comedy"}]', '["schulmans","podcast","eklund","sigge","sigges","schulman","eklunds","alex","radio","podradio"]', 'Alex Schulmans och Sigge Eklunds podcast som publiceras en gång i veckan.', 'http://assets.libsyn.com/content/4601369.jpg', 1386022416000, 1, 0, 0, NULL, NULL, NULL), (73, 'http://computersweden.libsyn.com/rss', 'http://computersweden.libsyn.com/rss', 'Computer Swedens podcast', 'CS ger dig koll på veckans viktigaste it-händelser', 'http://computersweden.libsyn.com', 'Bjorn Olsberg', 'bjorn.olsberg@idg.se', '[{"name":"Technology","subCategory":"Podcasting"},{"name":"News \u0026 Politics"},{"name":"Technology","subCategory":"Tech News"}]', '["computer","cs","sweden"]', 'Lyssna i stället för att läsa! I Computer Swedens podcast sammanfattar vi it-nyheterna den senaste veckan, med fokus på de tre ämnen som vi tycker är intressantast att diskutera. Nyhetschef Sverker Brundin, debattredaktör Eva Melin och teknikreporter Tomas Zirn blandar hårt med mjukt och högt med lågt varje torsdag kl 17.00.', 'http://assets.libsyn.com/content/6406700.jpg', 1386023131000, 1, 0, 0, NULL, NULL, NULL), (212, 'http://feeds.feedburner.com/ThisIsMyNextPodcast', 'http://feeds.feedburner.com/ThisIsMyNextPodcast', 'The Vergecast', 'The Vergecast', 'http://www.theverge.com/verge/verge_archives/show?mode=EntryGroup&slug=the-vergecast', 'Joshua Topolsky, Nilay Patel, Paul Miller', 'joshua@theverge.com', '[{"name":"Technology","subCategory":"Tech News"},{"name":"Technology","subCategory":"Gadgets"},{"name":"Technology"}]', '["joshua","gadgets","pcs","this","mac","smartphones","technology","miller","next","apple","pc","gadget","google","laptops","macs","is","paul","tech","ipad","patel","news","nilay","iphone","windows","android","timp","osx","podcast","my","topolsky","microsoft","tablet","tabelts"]', 'The Vergecast is your source for an irreverent and informative look at what''s happening right now (and next) in the world of technology and gadgets. Hosted by Joshua Topolsky, Nilay Patel, and Paul Miller alongside a cavalcade of tech luminaries, The Vergecast is the only podcast you need to make sense of the week in tech news. And your life.', 'http://assets.sbnation.com/assets/770431/vergecast.png', 1382873693000, 1, 0, 0, NULL, NULL, NULL), (173, 'http://feeds.feedburner.com/Iterate', 'http://feeds.feedburner.com/Iterate', 'Iterate', 'Iterate: Loop until done.', 'http://www.iterate.tv/', 'Edwards, Clifford, Ritchie', 'rene@mobilenations.com', '[{"name":"Arts","subCategory":"Design"},{"name":"Technology","subCategory":"Software How-To"}]', '["icons","windows","interface","design","ipad","x","ux","blackberry","ui","webos","user","phone","iphone","mac","android","experience","os"]', 'Iterate brings together the best designers and app producers in the business to talk user interface and user experience from concept to implementation. Hosted by Marc Edwards, Seth Clifford, and Rene Ritchie. Loop until done.', 'http://www.mobilenations.com/broadcasting/podcast_iterate_1400.jpg', 1382885371000, 1, 0, 0, NULL, NULL, NULL)

该语句导致此堆栈跟踪:

android.database.sqlite.SQLiteException: near ",": syntax error: , while compiling: 
    at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method) ~[na:0.0]
    at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:68) ~[na:0.0]
    at android.database.sqlite.SQLiteProgram.compileSql(SQLiteProgram.java:143) ~[na:0.0]
    at android.database.sqlite.SQLiteProgram.compileAndbindAllArgs(SQLiteProgram.java:361) ~[na:0.0]
    at android.database.sqlite.SQLiteStatement.acquireAndLock(SQLiteStatement.java:260) ~[na:0.0]
    at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:84) ~[na:0.0]
    at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:2019) ~[na:0.0]
    at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1959) ~[na:0.0]

这里有一些更详细的设备信息:

DEVICE
======
display name: IMM76D.XXLPV
manufacturer: samsung
model:        GT-P7310
product:      GT-P7310
brand:        samsung
tags:         release-keys

Android详细信息:

ANDROID
=======
release:  4.0.4
codename: REL
sdk:      15
locale:   sv_SE

4 个答案:

答案 0 :(得分:6)

使用单个SQL语句插入多行的语法支持仅为added in sqlite 3.7.11。一些制造商在他们的设备中使用旧版本的sqlite。不是平台碎片乐趣,呃。

您可以通过分解插入来一次插入一行来修复它。

在此期间,还应考虑更改为?文字占位符,并使用bindArgsexecSQL()来提供值。或者只使用ContentValuesinsert()

为了提高性能,请在单个数据库事务中包装多个插入(例如,最多1000个)。

答案 1 :(得分:1)

你能不能先尝试插入一半的行,然后再插入一半,然后保持一半,直到找到造成问题的行/行。应该更容易发现问题。

答案 2 :(得分:0)

我建议您使用参数来插入值here是一种很好的方法

答案 3 :(得分:0)

以拉尔托的答案为基础,

使用db.beginTransaction();然后循环并插入包含initialValues = new ContentValues();initialValues.put(KEY_CATEGORY, category);等的行..然后在结尾写db.setTransactionSuccessful();db.endTransaction();

我用它在5秒内插入9k行。