gpt4 book ai didi

java - E/SQLite数据库 : Error inserting with SQLiteConstraintException

转载 作者:行者123 更新时间:2023-12-02 10:19:30 27 4
gpt4 key购买 nike

在我的应用程序的这一部分中,我尝试将从改造 onResponse 方法获取的结果数据保存到 sqlite 数据库中,但我在 android.database 中收到多个 E/SQLiteDatabase: Error inserting 错误。 database.sqlite.SQLiteConstraintException:UNIQUE约束失败:

日志

    E/SQLiteDatabase: Error inserting kind=blogger#post etag="iHf3yWDE_geBgZ8U7rgZ_xuTeAQ/dGltZXN0YW1wOiAxNTQ4NTAwNzI5NjI4Cm9mZnNldDogNzIwMDAwMAo" id=2632206540636403989 published=2019-01-26T10:44:00+02:00 updated=2019-01-26T13:05:29+02:00 url=http://www.pro-cs-is.com/2019/01/view-see-saved-wifi-password-android.html content=<div dir="rtl" style="text-align: right;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-BgpwbrxNNxo/XEoAkKz4SQI/AAAAAAAAHQI/tNDvQUT1dLI6sb8aAU6xnAg0TK_HsNrmgCLcBGAs/s1600/%25D8%25B5%25D9%2588%25D8%25B1%25D8%25A9%2B%25D8%25A7%25D9%2584%25D9%2585%25D9%2588%25D8%25B6%25D9%2588%25D8%25B9.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="1280" height="360" src="https://4.bp.blogspot.com/-BgpwbrxNNxo/XEoAkKz4SQI/AAAAAAAAHQI/tNDvQUT1dLI6sb8aAU6xnAg0TK_HsNrmgCLcBGAs/s640/%25D8%25B5%25D9%2588%25D8%25B1%25D8%25A9%2B%25D8%25A7%25D9%2584%25D9%2585%25D9%2588%25D8%25B6%25D9%2588%25D8%25B9.jpg" width="640" /></a></div>
<br />
<br />
<div class="MsoNormal" dir="RTL">
<span lang="AR-EG" style="font-family: &quot;tahoma&quot; , sans-serif; font-size: 14.0pt; line-height: 107%;">في بعض الأحيان ينسى مستخدمي الهواتف الذكية كلمة مرور شبكة ال WiFi المتصلين بها في الأماكن العامة أو العمل ويحتاجونها لمشاركتها مع الأصدقاء أو لأي أغراض آخرى، في هذا الموضوع سأقوم بشرح طريقتين لإستخراج كلمات مرور شبكات الواي فاي المحفوظة على هواتف الأندرويد.</span></div>
<a name='more'></a><br />
<blockquote class="tr_bq">
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;"><b>ملحوظة : جميع الطرق تحتاج إلى صلاحيات مدير النظام (Root)</b></span></span></blockquote>
<span style="font-family: &quot;tahoma&quot; , sans-serif; font-size: 18.6667px;">إذا لم يكن بهاتفك صلاحيات مدير النظام يمكنك الإطلاع على هذا الموضوع&nbsp;<a href="https://www.pro-cs-is.com/2016/08/how-to-root-android.html" target="_blank">أفضل برامج للحصول على صلاحيات مدير النظام (Root) لجهازك الأندرويد</a></span><br />
<br />
<h3 style="text-align: right;">
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;">الطريقة الأولى :</span></span></h3>
<div>
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;">عن طريق تطبيق <a href="https://play.google.com/store/apps/details?id=htmt.wifipassword" rel="nofollow" target="_blank">WiFi Password, IP, DNS</a></span></span><br />
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-usMjRJwPBwE/XEr1aoQyhBI/AAAAAAAAHRM/eUj9EDxzrBkSKb6G09P2Y4iYPpzTO7SwACLcBGAs/s1600/WiFi%2BPassword%252C%2BIP%252C%2BDNS.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="632" data-original-width="1063" height="380" src="https://4.bp.blogspot.com/-usMjRJwPBwE/XEr1aoQyhBI/AAAAAAAAHRM/eUj9EDxzrBkSKb6G09P2Y4iYPpzTO7SwACLcBGAs/s640/WiFi%2BPassword%252C%2BIP%252C%2BDNS.jpg" width="640" /></a></div>
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><br /></span></div>
<div>
<br /></div>
<div>
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;">بعد تحميل وتنصيب التطبيق قم بفتحه ثم إضغط على <b>Show WiFi Profiles</b>&nbsp;سيطلب التطبيق صلاحيات مدير النظام (root) قم بمنحه أياها</span></span><br />
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;"><br /></span><
E/SQLiteDatabase: <a href="https://3.bp.blogspot.com/-R39qwUmqxBU/XEsCIo2NSLI/AAAAAAAAHRY/cLvsxmXKadkqTPrjgH_4JrIGLJvfwiobwCLcBGAs/s1600/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A5-%25D9%25A1%25D9%25A3-%25D9%25A2%25D9%25A5-%25D9%25A4%25D9%25A7.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1280" data-original-width="720" height="640" src="https://3.bp.blogspot.com/-R39qwUmqxBU/XEsCIo2NSLI/AAAAAAAAHRY/cLvsxmXKadkqTPrjgH_4JrIGLJvfwiobwCLcBGAs/s640/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A5-%25D9%25A1%25D9%25A3-%25D9%25A2%25D9%25A5-%25D9%25A4%25D9%25A7.png" width="360" /></a></div>
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;"><br /></span></span>
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;">بعدها ستجد مباشرة جميع معلومات الشبكات التي قمت بالإتصال بها في هاتفك و كلمة المرور أمام كلمة <b>Password</b></span></span><br />
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;"><br /></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-ikGMUxJyx8A/XEsFxFb3oRI/AAAAAAAAHRw/ByDdHVNO4Qgak5MLF49BnJT1m2q_timbQCLcBGAs/s1600/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A5-%25D9%25A1%25D9%25A3-%25D9%25A4%25D9%25A3-%25D9%25A1%25D9%25A7.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1280" data-original-width="720" height="640" src="https://4.bp.blogspot.com/-ikGMUxJyx8A/XEsFxFb3oRI/AAAAAAAAHRw/ByDdHVNO4Qgak5MLF49BnJT1m2q_timbQCLcBGAs/s640/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A5-%25D9%25A1%25D9%25A3-%25D9%25A4%25D9%25A3-%25D9%25A1%25D9%25A7.png" width="360" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;"><br /></span></span>
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;"><br /></span></span>
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;"><b>الطريقة الثانية :</b></span></span><br />
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;"><br /></span></span></div>
<div>
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;">عن طريق تطبيق <b><a href="https://play.google.com/store/apps/details?id=com.estrongs.android.pop" rel="nofollow" target="_blank">Es File Explorer File Manger</a></b></span></span><br />
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;"><br /></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-a4bq9s_j3LI/XEsmj8E6x6I/AAAAAAAAHSM/ZiHDgBUKOMkYMIbMpeHPmmvMKuuXOWbLwCLcBGAs/s1600/Es%2BFile%2BExplorer%2BFile%2BManger.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="632" data-original-width="1110" height="364" src="https://4.bp.blogspot.com/-a4bq9s_j3LI/XEsmj8E6x6I/AAAAAAAAHSM/ZiHDgBUKOMkYMIbMpeHPmmvMKuuXOWbLwCLcBGAs/s640/Es%2BFile%2BExplorer%2BFile%2BManger.jpg" width="640" /></a></div>
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;"><br /></span></span><span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;">بعد تحميل وتنصيب التطبيق قم بفتحه ثم قم بالنقر على الثلاثة خطوط المتواجدين بالأعلى لفتح القائمة الجانبية</span></span><br />
<span s
E/SQLiteDatabase: <div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-5J70yswDwPs/XEwRZWO5wkI/AAAAAAAAHSc/LbdMQ7RJOCgzhFT7dnRBeKqOx0gEXuQPACLcBGAs/s1600/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A4-%25D9%25A0%25D9%25A9-%25D9%25A3%25D9%25A3-%25D9%25A0%25D9%25A7.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1280" data-original-width="720" height="640" src="https://4.bp.blogspot.com/-5J70yswDwPs/XEwRZWO5wkI/AAAAAAAAHSc/LbdMQ7RJOCgzhFT7dnRBeKqOx0gEXuQPACLcBGAs/s640/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A4-%25D9%25A0%25D9%25A9-%25D9%25A3%25D9%25A3-%25D9%25A0%25D9%25A7.png" width="360" /></a></div>
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;"><br /></span></span>
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;">من القائمة الجانبية قم بالنزول حتى تجد خيار <b>متصفح ملفات النظام</b>&nbsp;و إضغط عليه،&nbsp;</span></span><span style="font-family: &quot;tahoma&quot; , sans-serif; font-size: 18.6667px;">سيطلب التطبيق صلاحيات مدير النظام (root) قم بمنحه أياها</span><br />
<span style="font-family: &quot;tahoma&quot; , sans-serif; font-size: 18.6667px;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-hV9L8BK77Vc/XEwSxR1SabI/AAAAAAAAHSo/9uziSP0y0GsHvaKeAseLi5Coi4zWXmuugCLcBGAs/s1600/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A4-%25D9%25A0%25D9%25A9-%25D9%25A3%25D9%25A3-%25D9%25A5%25D9%25A6.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1280" data-original-width="720" height="640" src="https://4.bp.blogspot.com/-hV9L8BK77Vc/XEwSxR1SabI/AAAAAAAAHSo/9uziSP0y0GsHvaKeAseLi5Coi4zWXmuugCLcBGAs/s640/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A4-%25D9%25A0%25D9%25A9-%25D9%25A3%25D9%25A3-%25D9%25A5%25D9%25A6.png" width="360" /></a></div>
<span style="font-family: &quot;tahoma&quot; , sans-serif; font-size: 18.6667px;"><br /></span>
<span style="font-family: &quot;tahoma&quot; , sans-serif; font-size: 18.6667px;">بعد منح التطبيق الصلاحيات، من نفس القائمة قم بالنزول إلى الأسفل حتى تجد خيار محلي أو Local إذا كانت لغة الهاتف بالإنجليزية</span><br />
<span style="font-family: &quot;tahoma&quot; , sans-serif; font-size: 18.6667px;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-wTj8cDUCqvE/XEwT_KiYjfI/AAAAAAAAHS0/Fb8gaeNopFg4Cwz9c8rIgNCWX2-mpTdDgCLcBGAs/s1600/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A4-%25D9%25A1%25D9%25A0-%25D9%25A0%25D9%25A9-%25D9%25A0%25D9%25A3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1280" data-original-width="720" height="640" src="https://4.bp.blogspot.com/-wTj8cDUCqvE/XEwT_KiYjfI/AAAAAAAAHS0/Fb8gaeNopFg4Cwz9c8rIgNCWX2-mpTdDgCLcBGAs/s640/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A4-%25D9%25A1%25D9%25A0-%25D9%25A0%25D9%25A9-%25D9%25A0%25D9%25A3.png" width="360" /></a></div>
<span style="font-family: &quot;tahoma&quot; , sans-serif; font-size: 18.6667px;"><br /></span>
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;">بعدها اختر الجهاز/Device</span></span><br />
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;"><br /></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-t_nZeL67iqI/XEwUkXGZHRI/AAAAAAAAHS8/CckDMyA7j7kBeqsOqktMDx7hJZ9ATLtDgCLcBGAs/s1600/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A4-%25D9%25A1%25D9%25A0-%25D9%25A0%25D9%25A9-%25D9%25A2%25D9%25A0.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1280" data-original-width="720" height="640" src="https://4.bp.blogspot.com/-t_nZeL67iqI/XEwUkXGZHRI/AAAAAAAAHS8/CckDMyA7j7kBeqsOqktMDx7hJZ9ATLtDgCLcBGAs/s640/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A4-%25D9%25A1%25D9%25A0-%25D9%25A0%25D9%25A9-%25D9%25A2%25D9%25A0.png" width="360" /></a></div>
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;"><br /></span></span>
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;">سيقوم التطبيق بفتح مجلدات النظام نحتاج إلى الوصول إلى هذا المسار</span></span><br />
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;"><br /></span></span>
<br />
<blockquote class="tr_bq">
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;"><b>data/misc/wifi/</b></span></span></blockquote>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-MBtwL3CjvH0/XEwVs2iZSsI/AAAAAAAAHTI/x5OUCa7sPNUW-s6MlAp6D-Qvqolgwm9igCLcBGAs/s1600/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A4-%25D9%25A1%25D9%25A0-%25D9%25A1%25D9%25A0-%25D9%25A5%25D9%25A4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1280" data-original-width="720" height="640" src="https://3.bp.blogspot.com/-MBtwL3CjvH0/XEwVs2iZSsI/AAAAAAAAHTI/x5OUCa7sPNUW-s6MlAp6D-Qvqolgwm9igCLcBGAs/s640/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A4-%25D9%25A1%25D9%25A0-%25D9%25A1%25D9%25A0-%25D9%25A5%25D9%25A4.png" width="360" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-j1voZIdovWE/XEwV-5uM4II/AAAAAAAAHTQ/HnqSCmMGnWsOEQSMBorDsxaty9NJnXa_ACLcBGAs/s1600/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A4-%25D9%25A1%25D9%25A0-%25D9%25A1%25D9%25A1-%25D9%25A1%25D9%25A8.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1280" data-original-width="720" height="640" src="https://1.bp.blogspot.com/-j1voZIdovWE/XEwV-5uM4II/AAAAAAAAHTQ/HnqSCmMGnWsOEQSMBorDsxaty9NJnXa_ACLcBGAs/s640/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A4-%25D9%25A1%25D9%25A0-%25D9%25A1%25D9%25A1-%25D9%25A1%25D9%25A8.png" width="360" /></a></div>
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;"><br /></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-36O8nUlF20k/XEwWVO7oJ2I/AAAAAAAAHTY/3Uv4IBwUpeYGiIiArOWmaA7-yFx3bhhIgCLcBGAs/s1600/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A4-%25D9%25A1%25D9%25A0-%25D9%25A1%25D9%25A1-%25D9%25A3%25D9%25A9.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1280" data-original-width="720" height="640" src="https://3.bp.blogspot.com/-36O8nUlF20k/XEwWVO7oJ2I/AAAAAAAAHTY/3Uv4IBwUpeYGiIiArOWmaA7-yFx3bhhIgCLcBGAs/s640/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A4-%25D9%25A1%25D9%25A0-%25D9%25A1%25D9%25A1-%25D9%25A3%25D9%25A9.png" width="360" /></a></div>
<br />
E/SQLiteDatabase: <span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;">وأخيراً ستجد ملف <b>wpa_supplicant.conf</b>&nbsp;والذي يحتوي على معلومات جميع الشبكات التي قمت بالإتصال بها على الهاتف، إضغط عليه لفتحه</span></span><br />
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;"><br /></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-JSeNFvpHZj0/XEwXcvY_SJI/AAAAAAAAHTk/1eLPEKsQDD8KMSQk0wHjw8Acpnx3NegBgCLcBGAs/s1600/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A4-%25D9%25A1%25D9%25A0-%25D9%25A1%25D9%25A2-%25D9%25A0%25D9%25A6.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1280" data-original-width="720" height="640" src="https://4.bp.blogspot.com/-JSeNFvpHZj0/XEwXcvY_SJI/AAAAAAAAHTk/1eLPEKsQDD8KMSQk0wHjw8Acpnx3NegBgCLcBGAs/s640/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A4-%25D9%25A1%25D9%25A0-%25D9%25A1%25D9%25A2-%25D9%25A0%25D9%25A6.png" width="360" /></a></div>
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;"><br /></span></span>
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;">قم بإختيار محرر النصوص الخاص بالتطبيق ES ، <b>لن يفتح بأي محرر نصوص آخر</b></span></span><br />
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;"><b><br /></b></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-s26DQfuJHbg/XEwX91ju0oI/AAAAAAAAHTs/SkTVzX6MjJ8AxxrO-uWvhXPRPfuYSgb7QCLcBGAs/s1600/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A4-%25D9%25A1%25D9%25A0-%25D9%25A1%25D9%25A3-%25D9%25A1%25D9%25A0.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1280" data-original-width="720" height="640" src="https://3.bp.blogspot.com/-s26DQfuJHbg/XEwX91ju0oI/AAAAAAAAHTs/SkTVzX6MjJ8AxxrO-uWvhXPRPfuYSgb7QCLcBGAs/s640/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A4-%25D9%25A1%25D9%25A0-%25D9%25A1%25D9%25A3-%25D9%25A1%25D9%25A0.png" width="360" /></a></div>
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;"><b><br /></b></span></span>
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;">ستجد مباشرة جميع معلومات الشبكات في هذا الملف من ضمنها كلمات المرور أمام كلمة <b>"psk"</b></span></span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-oS5PZl4rnX4/XEwYfFUUFBI/AAAAAAAAHT4/NS8GVEFg2mwqTkVbwUYT9iSyhChdyLVfgCLcBGAs/s1600/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A4-%25D9%25A1%25D9%25A0-%25D9%25A1%25D9%25A9-%25D9%25A1%25D9%25A0.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1280" data-original-width="720" height="640" src="https://2.bp.blogspot.com/-oS5PZl4rnX4/XEwYfFUUFBI/AAAAAAAAHT4/NS8GVEFg2mwqTkVbwUYT9iSyhChdyLVfgCLcBGAs/s640/Screenshot_%25D9%25A2%25D9%25A0%25D9%25A1%25D9%25A9-%25D9%25A0%25D9%25A1-%25D9%25A2%25D9%25A4-%25D9%25A1%25D9%25A0-%25D9%25A1%25D9%25A9-%25D9%25A1%25D9%25A0.png" width="360" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<blockquote class="tr_bq">
<span style="font-family: &quot;tahoma&quot; , sans-serif;"><span style="font-size: 18.6667px;"><b>بعض الشبكات لن تجد هذا السطر و هذا معناه إنها شبكة مفتوحة "بدون ك�
E/SQLiteDatabase: android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: items.id (code 1555)
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:783)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1548)
at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1417)
at www.pro_cs_is.com.ItemsDBHelper.addItem(ItemsDBHelper.java:72)
at www.pro_cs_is.com.MainActivity$2.onResponse(MainActivity.java:198)
at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:70)
at android.os.Handler.handleCallback(Handler.java:794)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:173)
at android.app.ActivityThread.main(ActivityThread.java:6653)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:821)

Which I understood from the log that there was a mistake in writing the Syntax for creating the ITEMS_TABLE but I reviewed it several times and everything seems to be fine

Note: I trying to replace KEY_ID primary key index to the second and make KEY_KIND first in the sql clause such as its location in the defined class but the same result!

ItemsDBHelper 类

    public class ItemsDBHelper extends SQLiteOpenHelper {


private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "itemsInfo";
private static final String TABLE_NAME = "items";
private static final String KEY_KIND = "kind";
private static final String KEY_ID = "id";
private static final String KEY_PUBLISHED = "published";
private static final String KEY_UPDATED = "updated";
private static final String KEY_ETAG = "etag";
private static final String KEY_URL = "url";
private static final String KEY_SELFLINK = "selfLink";
private static final String KEY_CONTENT = "content";
private static final String KEY_LABELS = "labels";

public ItemsDBHelper(Context context){
super(context,DATABASE_NAME,null,DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
Log.e("oncreate","oncreate");
String CREATE_ITEMS_TABLE = "CREATE TABLE "+ TABLE_NAME + " ("+KEY_ID+" INTEGER PRIMARY KEY, "+KEY_KIND+" TEXT, "+KEY_PUBLISHED+" TEXT, "
+KEY_UPDATED+" TEXT, "+KEY_ETAG+" TEXT, "+KEY_URL+" TEXT, "
+KEY_SELFLINK+" TEXT, "+KEY_CONTENT+" TEXT, "+KEY_LABELS+" TEXT)";

db.execSQL(CREATE_ITEMS_TABLE);
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.e("onupgrade","onupgrade");
db.execSQL("DROP TABLE IF EXISTS "+TABLE_NAME);
onCreate(db);
}

public void addItem(Item item){
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_ID,item.getId());
values.put(KEY_KIND,item.getKind());
values.put(KEY_PUBLISHED,item.getPublished());
values.put(KEY_UPDATED,item.getUpdated());
values.put(KEY_ETAG,item.getEtag());
values.put(KEY_URL,item.getUrl());
values.put(KEY_SELFLINK,item.getSelfLink());
values.put(KEY_CONTENT,item.getContent());
values.put(KEY_LABELS,convertListToString(item.getLabels()));

db.insert(TABLE_NAME,null,values);
db.close();
}

public Item getItem(int id){
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(TABLE_NAME,
new String[]{KEY_ID,KEY_KIND,KEY_PUBLISHED,
KEY_UPDATED,KEY_ETAG,KEY_URL,KEY_SELFLINK,KEY_CONTENT},KEY_ID+"=?",
new String[]{String.valueOf(id)},null,null,null,null);
Item item=null;
if(cursor!=null){
cursor.moveToFirst();
item = new Item();
}
return item;
}

public List<Item> getAllShops(){
List<Item> items = new ArrayList<>();
SQLiteDatabase dp = this.getReadableDatabase();
String selectQuery = "SELECT * FROM "+TABLE_NAME;
Cursor cursor = dp.rawQuery(selectQuery,null);
if(cursor!=null){
if(cursor.moveToFirst()){
do{
Item item = new Item();
item.setId(cursor.getString(0));
item.setKind(cursor.getString(1));
item.setPublished(cursor.getString(2));
item.setUpdated(cursor.getString(3));
item.setEtag(cursor.getString(4));
item.setUrl(cursor.getString(5));
item.setSelfLink(cursor.getString(5));
item.setContent(cursor.getString(6));
item.setLabels(convertStringToList(cursor.getString(7)));

items.add(item);
}while (cursor.moveToNext());
}
}
return items;
}

private static final String LIST_SEPARATOR = "__,__";

public static String convertListToString(List<String> stringList) {
StringBuilder stringBuilder = new StringBuilder();
for (String str : stringList) {
stringBuilder.append(str).append(LIST_SEPARATOR);
}

// Remove last separator
stringBuilder.setLength(stringBuilder.length() - LIST_SEPARATOR.length());

return stringBuilder.toString();
}

public static List<String> convertStringToList(String str) {
return Arrays.asList(str.split(LIST_SEPARATOR));
}
}

我在响应方法中这样使用了它

final Call<PostList> postList = BloggerAPI.getService().getPostList(url);
postList.enqueue(new Callback<PostList>() {
@Override
public void onResponse(Call<PostList> call, Response<PostList> response) {
PostList list = response.body();
token = list.getNextPageToken();
items.addAll(list.getItems());

for (int i = 0 ; i< items.size();i++) {
itemsDBHelper = new ItemsDBHelper(MainActivity.this);
itemsDBHelper.addItem(items.get(i));
}

Item item1 = itemsDBHelper.getItem(0);
Log.e("TEST ITEM 01",item1.getTitle()+ "\n" + item1.getUrl());
Item item2 = itemsDBHelper.getItem(1);
Log.e("TEST ITEM 01",item2.getTitle()+ "\n" + item2.getUrl());



adapter.notifyDataSetChanged();
Toast.makeText(MainActivity.this, "Sucess", Toast.LENGTH_LONG).show();
}

@Override
public void onFailure(Call<PostList> call, Throwable t) {
Toast.makeText(MainActivity.this,"Error occured",Toast.LENGTH_LONG).show();
Log.i(TAG, "onFailure: "+t.toString());
}
});

最佳答案

问题是 id 列不是唯一的,这不是一个错误,而是异常已被捕获,因为实际上正在使用 INSERT OR IGNORE,但正在写入到日志。然而,当发生这种情况时,该行将不会被插入。

id 列是使用 INTEGER PRIMARY KEY 定义的,这意味着 UNIQUE 约束,它另外使该列成为 rowid 的别名,从而使该列具有一个特殊属性/处理情况。也就是说,如果没有指定值,那么 SQLite 将生成一个唯一的值。该值将是一个唯一的 64 位有符号整数,最初为 1,然后通常比最后一个值大 1。

通常不会为此类列提供任何值,而是使用 SQLite 生成的值。

我建议您更改为使用典型用途,从而相应地修改您的 addItem 方法,例如:-

public long addItem(Item item){ //<<<<<<<<<< returns long (id assigned by SQLite)
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
//values.put(KEY_ID,item.getId()); //<<<<<<<<<< allow SQLite to assign id
values.put(KEY_KIND,item.getKind());
values.put(KEY_PUBLISHED,item.getPublished());
values.put(KEY_UPDATED,item.getUpdated());
values.put(KEY_ETAG,item.getEtag());
values.put(KEY_URL,item.getUrl());
values.put(KEY_SELFLINK,item.getSelfLink());
values.put(KEY_CONTENT,item.getContent());
values.put(KEY_LABELS,convertListToString(item.getLabels()));

db.insert(TABLE_NAME,null,values);
db.close();
}

插入行后,您应该使用 addItem 方法返回的值(如果该对象)在 item 对象中设置 id随后将被使用。

关于java - E/SQLite数据库 : Error inserting with SQLiteConstraintException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54444303/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com