导出数据库的代码如下。字符串值在string.xml
中声明,存储在res的values文件夹中。日食在字符串中显示错误。虽然在string.xml
错误为:
ApplicationExportManager_error_exporting_to_sd_exclamation cannot be resolved or is not a field.
ApplicationExportManager_export cannot be resolved or is not a field.
ApplicationExportManager_export_database_question cannot be resolved or is not a field.
ApplicationExportManager_export_successful_exclamation cannot be resolved or is not a field.
ApplicationExportManager_export_textsecure_database_keys_and_settings_prompt annot be resolved or is not a field.
javacode
public void exportDatabase() {
Log.w("ApplicationExportManager", "Context: " + context);
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(context);
alertBuilder.setTitle(R.string.ApplicationExportManager_export_database_question);
alertBuilder.setMessage(R.string.ApplicationExportManager_export_textsecure_database_keys_and_settings_prompt);
alertBuilder.setCancelable(false);
alertBuilder.setPositiveButton(R.string.ApplicationExportManager_export, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
task = TASK_EXPORT;
progressDialog = new ProgressDialog(context);
progressDialog.setTitle(context.getString(R.string.ApplicationExportManager_exporting_database_and_keys));
progressDialog.setMessage(context
.getString(R.string.ApplicationExportManager_exporting_your_sms_database_keys_and_settings));
progressDialog.setCancelable(false);
progressDialog.setIndeterminate(true);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.show();
new Thread(ApplicationExportManager.this).start();
}
});
string.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">TextSecure</string>
<string name="yes">Yes</string>
<string name="no">No</string>
<string name="delete">Delete</string>
<!-- ApplicationExportManager -->
<string name="ApplicationExportManager_import_database_and_settings_title">Import Database and Settings?</string>
<string name="ApplicationExportManager_import_database_and_settings_message">Import TextSecure database, keys, and settings from the SD Card?\n\nWARNING: This will clobber any existing messages, keys, and settings!</string>
<string name="ApplicationExportManager_importing_database_and_keys">Importing Database and Keys</string>
<string name="ApplicationExportManager_importing_your_sms_database_keys_and_settings">Importing your SMS database, keys, and settings...</string>
<string name="ApplicationExportManager_export_database_question">Export Database?</string>
<string name="ApplicationExportManager_export_textsecure_database_keys_and_settings_prompt">Export TextSecure database, keys, and settings to the SD Card?</string>
<string name="ApplicationExportManager_exporting_database_and_keys">Exporting Database and Keys</string>
<string name="ApplicationExportManager_exporting_your_sms_database_keys_and_settings">Exporting your SMS database, keys, and settings...</string>
<string name="ApplicationExportManager_no_sd_card_found_exclamation">No SD card found!</string>
<string name="ApplicationExportManager_error_exporting_to_sd_exclamation">Error exporting to SD!</string>
<string name="ApplicationExportManager_import_successful_exclamation">Import Successful!</string>
<string name="ApplicationExportManager_export_successful_exclamation">Export Successful!</string>
<string name="ApplicationExportManager_import">Import</string>
<string name="ApplicationExportManager_export">Export</string>