As I was building my Android application that uses an SQLite database I needed to determine what the actual data in the tables were due to the fact I had a bug in my application. I need a tool like sqlplus, toad or PLSQL that enables one to peer into the tables. I thought I could do this using the DDM perspective in the Eclipse Android plugin but this does not enable one to do so or rather I could not find a way to do this.
So here where the steps that I took to peer into my SQLite database tables.
First you need to get access to the SQLite database file where the information is stored. Since I am building using Eclipse I Pull the file via the DDMS view within Eclipse. The image below shows how this can be done within the Eclipse IDE.
After selecting on your database, in my case TASKS_DATABASE, you then select the Pull File you need to save it on your file system. Pull File will grab the file from your emulater and place it onto you file system directory.
Once saved you need a tool that will help you peer inside this data. I found a nice tool called SQLite Database Browser to do this exact task. After unzipping the downloaded file. Launch the database browser and Open the SQLite database file you just downloaded. Here is a screen shot of the SQLite utility before loading the file I just pulled from Eclipse DDM view.
This shows three database tables within my SQLite database. Choose the one you want to view and select on Browse Data. This will display the contents of the data as shown below.
Use this tool to peer inside your data like you would with Oracle PL/SQL or Toad tools into Oracle.
Now I did this for the database that resides on the Emulator. I believe you cannot do this to a database that reside on a real Android OS phone due to security reasons. Or at least I hope not.
There is also another way to view what is in your SQLite tables via the adb shell and querying the database from the shell.
First need to get into the adb shell and cd to the directory where your applications database resides.
In this example I cd data/data.
Now you need to cd to the application directory.
You will see the TASK_DATABASE file. To get into the database you now execute the following.
>sqlite3 TASKS_DATABASE shown below.
You can execute SQL to see what is in the tables.
This is my blog where I hope to post information about what I am doing technically and what my family is up to. I hope you enjoy
Tuesday, June 22, 2010
Wednesday, June 9, 2010
Google Maps Key
To get a Google Maps API key one has to first create an MD5 certificate fingerprint using the keytool from Java SDK.
Here is how I created that certificate using the keystore tool included in the JDK.
keystore -genkey -v -keystore delaney_keys.keystore -alias delaney_keys
You will go through a series of questions such as: name, city, password, etc
At the end of all the questions your keystore in my case delaney_keys.keystore will be created.
Now to get the MD5 key you execute the following command.
keystore -list -alias delaney_keys -keystore delaney_keys.keystore
You will be prompted for your password you entered above and once entered successfully the MD5 Certificate will be printed on the command line.
Using this to obtain your Google API Key
Go the Google API Registration page
Accept the terms on the agreement and enter the MD5 certificate that the keytool printed out above. After entering the MD5 and submitting the page you will be displayed with a valid Google Maps API key that you can then use within your Android application to call the Google Maps API.
Here is how I created that certificate using the keystore tool included in the JDK.
keystore -genkey -v -keystore delaney_keys.keystore -alias delaney_keys
You will go through a series of questions such as: name, city, password, etc
At the end of all the questions your keystore in my case delaney_keys.keystore will be created.
Now to get the MD5 key you execute the following command.
keystore -list -alias delaney_keys -keystore delaney_keys.keystore
You will be prompted for your password you entered above and once entered successfully the MD5 Certificate will be printed on the command line.
Using this to obtain your Google API Key
Go the Google API Registration page
Accept the terms on the agreement and enter the MD5 certificate that the keytool printed out above. After entering the MD5 and submitting the page you will be displayed with a valid Google Maps API key that you can then use within your Android application to call the Google Maps API.
Monday, May 24, 2010
Formatting LogCat Output
The output from an Android Logcat application can be quite difficult to determine problems especially without being in debug your application. Logcat is a great way to view the logs. I found a really nice python script that enables one to format the Logcat log so that the log types DEBUG, WARN, INFO, etc are colored making it easier to view.
Here is the output of such a log after piping the logcat to the python script;
This is a terminal output of the Logcat log. I captured this while running my Android application in debug mode within Eclipse. This log is much easier to read than the logcat that is within Eclipse.
How did I do this? execute the following on the terminal command line.
adb logcat | ~/tools/scripts/coloredlogcat.py
The coloredlogcat.py is a python script I got from colored. I stole this script from Jeff Sharkey, thanks Jeff.
Here is the output of such a log after piping the logcat to the python script;
This is a terminal output of the Logcat log. I captured this while running my Android application in debug mode within Eclipse. This log is much easier to read than the logcat that is within Eclipse.
How did I do this? execute the following on the terminal command line.
adb logcat | ~/tools/scripts/coloredlogcat.py
The coloredlogcat.py is a python script I got from colored. I stole this script from Jeff Sharkey, thanks Jeff.
Monday, May 17, 2010
Chrome Browser Plugin/Extension
Found this awesome little Chrome Browser plugin from BuiltWith . Actually Firefox calls them plugins for Chrome it is an extension.
With this extension you can determine all of the technologies any non-https website you visit uses. You will be able to determine what client side technologies and server-side web servers they use.
I used to determine this information by checking out the url and viewing the source of the page I was visiting for the libraries they pull into the page. This nice little extension enables one to simple ask.
I have not viewed how BuildWith is doing this. Not sure if they have a database of this information they have collected or they are determining this information at run-time.
Here is the href to the extension
With this extension you can determine all of the technologies any non-https website you visit uses. You will be able to determine what client side technologies and server-side web servers they use.
I used to determine this information by checking out the url and viewing the source of the page I was visiting for the libraries they pull into the page. This nice little extension enables one to simple ask.
I have not viewed how BuildWith is doing this. Not sure if they have a database of this information they have collected or they are determining this information at run-time.
Here is the href to the extension
Friday, May 14, 2010
Android Shared Preferences
Android has a concept of an application storing default information in a preference. Example would be when a user first down loads an Android application installs and configures the application with some setting like email or user name. During the setting of the application the information retrieved from the user can be stored in the SharedPreference API. This is a very easy way to save data that can be used later even after the application is stopped and restarted.
public class ConfigActivity extends Activity { public void onCreate( Bundle state ) { super.onCreate( state ); // Show the config settings in View saveButton = findByViewId(...); saveButton.setOnClickListener( new View.OnClickListener() { public void onClick(View v ) { saveEmail(user, pass); } }); // Get Email and place into config Text box }
protected void saveEmail( String user, String pass ) { SharedPreferences pref = null; getSharedPreferences( "EMAIL_SETTINGS", this.MODE_WORLD_WRITEABLE );
// Must edit and commit Editor edit = pref.edit(); edit.putString("emailName", user); edit.putString("emailPassword", pass); edit.commit(); }
protected String getEmail() { SharedPreferences pref = getSharedPreferences("EMAIL_SETTINGS", this.MODE_WORLD_READABLE ); String email = pref.getString( "emailName" , null); return email; }
}
Friday, May 7, 2010
UNIX via JavaScript
Just came across this JavaScript library JS/UIX Terminal that enables you to run UNIX within the browser. A lot, not all, of the unix commands work in this little tool. I find it amazing what developer can do with software. I am not sure why this person decided to build this what it can be used to do functionally I am not sure. Still pretty cool.
Possibly a good use for this would be to give your UNIX friendly users an interface they are used to in the browser.
Possibly a good use for this would be to give your UNIX friendly users an interface they are used to in the browser.
Subscribe to:
Posts (Atom)