[Android] Add debugging feature to clear database
Edward Wang
git at videolan.org
Sun Apr 15 19:33:05 CEST 2012
android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Fri Mar 23 07:35:57 2012 -0400| [8cef981e502137031f29881ad7eb32fa379f5fbb] | committer: Jean-Baptiste Kempf
Add debugging feature to clear database
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=8cef981e502137031f29881ad7eb32fa379f5fbb
---
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 74efb52..ac7c2f1 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 8e57057..9ecd551 100644
--- a/vlc-android/src/org/videolan/vlc/DatabaseManager.java
+++ b/vlc-android/src/org/videolan/vlc/DatabaseManager.java
@@ -475,5 +475,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
More information about the Android
mailing list