Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android SQLite语法错误,但仅在三星Galaxy选项卡上_Android_Sqlite_Samsung Mobile - Fatal编程技术网

Android SQLite语法错误,但仅在三星Galaxy选项卡上

Android SQLite语法错误,但仅在三星Galaxy选项卡上,android,sqlite,samsung-mobile,Android,Sqlite,Samsung Mobile,我有一个奇怪的问题,这似乎是特定于设备的:我的Android播客播放器应用程序从服务器获取数据并将其插入数据库。对于100多个用户来说,一切正常。但对于一个用户来说,数据插入失败,并出现SQLite语法错误,但只是在Android 4.0.4的Galaxy选项卡(GT-P7310)上。同一用户还拥有两部手机(Galaxy Nexus和Nexus 5),在这两部手机中,相同的数据可以正常工作 此外,我可以在本地SQLite安装中毫无问题地执行该语句 这是导致问题的语句,添加了一些换行符以提高可读性

我有一个奇怪的问题,这似乎是特定于设备的:我的Android播客播放器应用程序从服务器获取数据并将其插入数据库。对于100多个用户来说,一切正常。但对于一个用户来说,数据插入失败,并出现SQLite语法错误,但只是在Android 4.0.4的Galaxy选项卡(GT-P7310)上。同一用户还拥有两部手机(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]
Android的详细信息:

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

您不能先插入一半行,然后再插入另一半行,然后继续减半,直到找到导致问题的行。应该可以更容易地发现问题。

使用单个SQL语句插入多行的语法支持仅限于。一些制造商的设备中有较旧版本的sqlite。平台碎片化不是很有趣吗

您可以通过将插入拆分为一次插入一行来修复它

同时,还要考虑更改为<代码>?/COD>文字占位符,并使用<代码> BANDARGS < /代码>提供这些值。或者只需将

ContentValues
insert()一起使用即可


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

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

以laalto的答案为基础

使用
db.beginTransaction()然后循环并插入带有
initialValues=newcontentvalues()的行和<代码>初始值。放置(键\类别,类别)ect。。然后在末尾写入
db.setTransactionSuccessful()
db.endTransaction()


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

这是用户的设备,所以这有点困难。但是我会考虑为他建立一个特别的版本。IMHO,因为你的答案不是问题的解决方案(它只是进一步调查的提示)对我最初的问题发表评论会是一个更合适的选择。你这样做的原因是在一个庞大的声明中,而不是在一个交易中单独声明?另外,您不使用位置参数(
)?@commonware是否有原因?@commonware我已经将显示的几十条语句包装到一个事务中了。我的假设是,多插入仍然比多个单插入更快——即使使用准备好的语句。但我同意带位置参数的准备语句会是一个更好的选择,就是这样。在过去的一年里,我经历了很多关于Android碎片化的事情,但我没有想到,我十年来一直使用的SQL功能在Android 4上不受支持:-/BTW:我已经在使用事务,因为我插入了数百个细分为10个项目批次的项目。关于准备好的语句,您是对的,但是在这种情况下构建语句更容易,因为数据来自我自己的服务器安全性并不是一个主题。“一些制造商在他们的设备中有较旧版本的sqlite”——请注意,该功能仅在2012年3月才添加到sqlite本身()。“但我没有想到我十年来一直使用的SQL功能在Android 4上不受支持”——Android 4.0.4是在SQLite添加此功能九天后发布的,因此这并不是一个合理的期望。在安卓4.1+()上期望它是合理的,但正如laalto所指出的,制造商可以降低他们的SQLite的等级,尽管他们不应该这样做。我已经在使用transaction捆绑显示的几十条语句。这不是真正的问题,也不能解决问题。IMHO将此信息作为对laalto答案的评论将是一个更好的选择。
ANDROID
=======
release:  4.0.4
codename: REL
sdk:      15
locale:   sv_SE