Thursday, December 27, 2012

Use CellObject to browse Android SQLite data contents

This will only work with Android emulators or rooted phones.


Extract it. Find net.cellobject.sqlitexmlbrowser_1.2.0.jar.

Put net.cellobject.sqlitexmlbrowser_1.2.0.jar into the eclipce plugin directory.

Restart Eclipse.

Start the emulator.

Go to DDMS

Select your device on the left panel.

Then on the right side panel, navigate to 
data/data/{your_app_package_namespace}/databases/{app_name}
Click the database icon on the top bar of this right side panel.

You should now be able to see the table schema and browse the data in the CellObject SQLite Browser.

Sunday, December 16, 2012

Android selector needs drawable instead of just background


The following will result in a crash saying that cannot inflate the drawable.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_pressed="true" android:background="#000000" />
  <item android:state_focused="true" android:background="#000000" />
  <item android:background="#FFFFFF" />
</selector>

The solution is to change the background to use drawable

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_pressed="true" android:drawable="@color/grey" />
  <item android:state_focused="true" android:drawable="@color/grey" />
  <item android:drawable="@color/white" />
</selector>

android:drawable attribute does not accept raw color.

Define color.xml in res/values.

<?xml version="1.0" encoding="utf-8"?>
<resources>
     <color name="black">#000</color>
     <color name="white">#fff</color>
     <color name="grey">#cccccc</color>
</resources>


Android Listview RuntimeException - Your content must have a ListView whose id attribute is android.R.id.list

"Your content must have a listview whose id is android.r.id.list"

Just make sure your listview's id is @android:id/list.

<ListView
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >