Saving to SQLDB like in ch.34, but in a Criminal Intent app


#1

I’m having some issues with an app I am writing for a class. Before I say anything more, I want you to know that your book has put me light years ahead of what was to be covered in the class and I’m very happy I purchased your book! However, it seems that when I try to apply the database material from Ch.34 to an application almost exactly the same as the Criminal Intent app, I’m getting some strange results. First, the differences: My app has a minimum SDK of 8, a target SDK of 21, and the project build type was Android 5.0 (Android Open Source Project, API 21).

In place of the classes and methods that save and load data from a JSON file in memory, my application has an SQLiteOpenHelper, a CursorWrapper, a Singleton to manage the helper, and a CursorAdapter. All the files load to and from the database into the list view just fine, and I can even interact with the list view items. However, the text on the list view items is a light gray, and the onCreateOptionsMenu(Menu, MenuInflater) never gets called even though I have setHasOptionsMenu(bool) set to true as the second line in onCreate. I can still click on the items to get to and from the detail view for the given items on the list and modify them without a problem. I have thoroughly checked all code for errors and cannot find anything syntactically wrong. Have you run into this problem before? Any help would be greatly appreciated.


#2

Alright, it appears that I solved my own problem at the last minute. Apparently, Eclipse wasn’t appending the .xml extension to my menu file, so it kept failing to find the thing. For good measure, I also set the min, target, and max sdk’s to the same values used in Ch.33’s RunTracker. Everything runs optimally now without a hitch. For anyone else having the same issue, make sure you explicitly include .xml in the file names you use for your menus and layouts.