FATAL EXCEPTION:后台任务android.database.sqlite.SQLiteException:没有这样的表。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了FATAL EXCEPTION:后台任务android.database.sqlite.SQLiteException:没有这样的表。相关的知识,希望对你有一定的参考价值。
我已经在控制台上加载了apk,测试报告只有1个错误在单一设备上(Galaxy S3,android 4.3)。错误内容如下。
FATAL EXCEPTION: Background tasks
android.database.sqlite.SQLiteException: no such table: server_preferences (code 1): , while compiling: SELECT * FROM server_preferences WHERE (name = ?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1118)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:691)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1436)
at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:400)
at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:294)
at com.google.android.gm.provider.MailEngine.getServerPrefsCursor(MailEngine.java:1462)
at com.google.android.gm.provider.MailEngine.getCursorForReplyFromDefaultAddress(MailEngine.java:1466)
at com.google.android.gm.provider.MailEngine.notifyInitializationComplete(MailEngine.java:1371)
at com.google.android.gm.provider.MailEngine.access$1900(MailEngine.java:135)
at com.google.android.gm.provider.MailEngine$5.run(MailEngine.java:1291)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:176)
at android.os.HandlerThread.run(HandlerThread.java:61)
我并没有直接使用SQLite,而只是使用了 SettingsActivity
类,它实现了 AppCompatPreferenceActivity
(也许问题取决于这个类)。 我看到过其他类似的主题,但他们总是直接使用SQLite。这里是 SettingsActivity
我正在使用。
public class SettingsActivity extends AppCompatPreferenceActivity
private static final String TAG = SettingsActivity.class.getSimpleName();
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// load settings fragment
getFragmentManager().beginTransaction().replace(android.R.id.content, new MainPreferenceFragment()).commit();
public static class MainPreferenceFragment extends PreferenceFragment
@Override
public void onCreate(final Bundle savedInstanceState)
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref_main);
// gallery EditText change listener
//bindPreferenceSummaryToValue(findPreference(getString(R.string.key_gallery_name)));
// notification preference change listener
//bindPreferenceSummaryToValue(findPreference(getString(R.string.key_notifications_new_message_ringtone)));
// feedback preference click listener
/*Preference myPref = findPreference(getString(R.string.key_send_feedback));
myPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener()
public boolean onPreferenceClick(Preference preference)
sendFeedback(getActivity());
return true;
);*/
@Override
public boolean onOptionsItemSelected(MenuItem item)
if (item.getItemId() == android.R.id.home)
onBackPressed();
return super.onOptionsItemSelected(item);
private static void bindPreferenceSummaryToValue(Preference preference)
preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
PreferenceManager
.getDefaultSharedPreferences(preference.getContext())
.getString(preference.getKey(), ""));
/**
* A preference value change listener that updates the preference's summary
* to reflect its new value.
*/
private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener()
@Override
public boolean onPreferenceChange(Preference preference, Object newValue)
String stringValue = newValue.toString();
if (preference instanceof ListPreference)
// For list preferences, look up the correct display value in
// the preference's 'entries' list.
ListPreference listPreference = (ListPreference) preference;
int index = listPreference.findIndexOfValue(stringValue);
// Set the summary to reflect the new value.
preference.setSummary(
index >= 0 ?
listPreference.getEntries()[index] :
null);
else if (preference instanceof RingtonePreference)
// For ringtone preferences, look up the correct display value
// using RingtoneManager.
if (TextUtils.isEmpty(stringValue))
// Empty values correspond to 'silent' (no ringtone).
preference.setSummary(R.string.pref_ringtone_silent);
else
Ringtone ringtone = RingtoneManager.getRingtone(
preference.getContext(), Uri.parse(stringValue));
if (ringtone == null)
// Clear the summary if there was a lookup error.
preference.setSummary(R.string.summary_choose_ringtone);
else
// Set the summary to reflect the new ringtone display
// name.
String name = ringtone.getTitle(preference.getContext());
preference.setSummary(name);
else if (preference instanceof EditTextPreference)
if (preference.getKey().equals("key_gallery_name"))
// update the changed gallery name to summary filed
preference.setSummary(stringValue);
else
preference.setSummary(stringValue);
return true;
;
/**
* Email client intent to send support mail
* Appends the necessary device information to email body
* useful when providing support
*/
public static void sendFeedback(Context context)
String body = null;
try
body = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
body = "\n\n-----------------------------\nPlease don't remove this information\n Device OS: Android \n Device OS version: " +
Build.VERSION.RELEASE + "\n App Version: " + body + "\n Device Brand: " + Build.BRAND +
"\n Device Model: " + Build.MODEL + "\n Device Manufacturer: " + Build.MANUFACTURER;
catch (PackageManager.NameNotFoundException e)
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]
"contact@androidhive.info"
);
intent.putExtra(Intent.EXTRA_SUBJECT, "Query from android app");
intent.putExtra(Intent.EXTRA_TEXT, body);
context.startActivity(Intent.createChooser(intent, context.getString(R.string.choose_email_client)));
我在网上找到了这个类,它在所有其他设备上都能完美运行。
以上是关于FATAL EXCEPTION:后台任务android.database.sqlite.SQLiteException:没有这样的表。的主要内容,如果未能解决你的问题,请参考以下文章
[php] Fatal error: Class Exception not found in
E/AndroidRuntime: FATAL EXCEPTION: main [重复]
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #2
FATAL EXCEPTION: Thread-7890 java.lang.ExceptionInInitializerError