[Android] [PATCH] Add debugging feature to clear database
Jean-Baptiste Kempf
jb at videolan.org
Sun Apr 15 19:41:47 CEST 2012
Applied.
On 23/03/2012 12:35, Edward Wang wrote:
> ---
> vlc-android/res/values/strings.xml | 1 +
> vlc-android/res/xml/preferences.xml | 1 +
> .../src/org/videolan/vlc/DatabaseManager.java | 8 +++++++-
> .../org/videolan/vlc/gui/PreferencesActivity.java | 11 +++++++++++
> 4 files changed, 20 insertions(+), 1 deletions(-)
>
> diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
> index 28c78d3..c47d880 100644
> --- a/vlc-android/res/values/strings.xml
> +++ b/vlc-android/res/values/strings.xml
> @@ -66,6 +66,7 @@
> <string name="enable_iomx">Enable hardware accelerated decoding</string>
> <string name="advanced_debugging">Advanced Debugging</string>
> <string name="quit">Quit Application</string>
> +<string name="clear_media_db">Clear media database</string>
> <string name="detect_headset">Detect headset</string>
> <string name="detect_headset_detail">Pause on headset removed, Resume on headset inserted</string>
> <string name="refresh">Refresh</string>
> diff --git a/vlc-android/res/xml/preferences.xml b/vlc-android/res/xml/preferences.xml
> index 6db2533..9097da2 100644
> --- a/vlc-android/res/xml/preferences.xml
> +++ b/vlc-android/res/xml/preferences.xml
> @@ -34,6 +34,7 @@
> <PreferenceCategory android:title="@string/advanced_prefs_category">
> <PreferenceScreen android:title="@string/advanced_debugging">
> <Preference android:title="@string/quit" android:key="quit_app" android:enabled="true"/>
> +<Preference android:title="@string/clear_media_db" android:key="clear_media_db" android:enabled="true" />
> </PreferenceScreen>
> </PreferenceCategory>
> </PreferenceScreen>
> diff --git a/vlc-android/src/org/videolan/vlc/DatabaseManager.java b/vlc-android/src/org/videolan/vlc/DatabaseManager.java
> index 3b9cd13..15819a9 100644
> --- a/vlc-android/src/org/videolan/vlc/DatabaseManager.java
> +++ b/vlc-android/src/org/videolan/vlc/DatabaseManager.java
> @@ -488,5 +488,11 @@ public class DatabaseManager {
> public synchronized void clearSearchhistory() {
> mDb.delete(SEARCHHISTORY_TABLE_NAME, null, null);
> }
> -
> +
> + /**
> + * Empty the database for debugging purposes
> + */
> + public synchronized void emptyDatabase() {
> + mDb.delete(MEDIA_TABLE_NAME, null, null);
> + }
> }
> diff --git a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
> index aa2e4bc..8064161 100644
> --- a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
> +++ b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
> @@ -33,6 +33,7 @@ import android.preference.CheckBoxPreference;
> import android.preference.Preference;
> import android.preference.Preference.OnPreferenceClickListener;
> import android.preference.PreferenceActivity;
> +import android.widget.Toast;
>
> public class PreferencesActivity extends PreferenceActivity {
>
> @@ -114,6 +115,16 @@ public class PreferencesActivity extends PreferenceActivity {
> return true;
> }
> });
> + Preference clearMediaPref = (Preference)findPreference("clear_media_db");
> + clearMediaPref.setOnPreferenceClickListener(
> + new OnPreferenceClickListener() {
> +
> + public boolean onPreferenceClick(Preference preference) {
> + DatabaseManager.getInstance(getBaseContext()).emptyDatabase();
> + Toast.makeText(getBaseContext(), "Media database cleared!", Toast.LENGTH_SHORT);
> + return true;
> + }
> + });
> }
>
> @Override
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
More information about the Android
mailing list