android - SQLite 语法错误,但仅在 Samsung Galaxy Tab 上

标签 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

最佳答案

使用单个 SQL 语句插入多行的语法支持仅为 added in sqlite 3.7.11 .一些制造商的设备中有旧版本的 sqlite。平台 fragment 化不是很有趣吗?

您可以通过将插入分解为一次插入一行来解决此问题。

在那里,还可以考虑更改为 ? 文字占位符并使用 bindArgsexecSQL()提供值(value)。或者只是将 ContentValuesinsert() 一起使用。

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

关于android - SQLite 语法错误,但仅在 Samsung Galaxy Tab 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20905692/

相关文章:

android - 来自 ActivityGroup 的子 Activity 仅 "sometimes"调用 onBackPressed()

Android:像在 Google Keep 中一样勾选检查列表项

android - 如何从 React Native Android 模块访问 Activity?

sql - 在GROUP BY c之后如何计算(DISTINCT a,b)

android - 禁用或检测应用特定的省电模式

android - 接口(interface)回调上的 fragment 空指针异常

python - 为什么我在使用 SQLite 编写 fetchone() 时得到不正确的值?

sql - 如何选择每个项目具有最大时间戳的行集?

android - 在 Samsung Galaxy 设备上选择图像旋转

android - 三星 Galaxy Note 3 SM-N9005 google play 控制台设备目录