obtaining cursor from sqlite database


I've tried to follow a tutorial on accessing sqlite databases on android and i've made it so far.

my code gets to "columns[] created" and then i get a null pointer exception...

I believe my database is populated but i have no way of really telling. can someone show me how to check? / get this working?

public Cursor getAnimalCursor() { System.out.println("in getAnimalCursor()"); String[] columns = new String[] {"_id", "name"}; System.out.println("columns[] created"); Cursor c = myDataBase.query("animals", null, null, null, null, null, null); System.out.println("cursor created"); return c; }


Check if you have initialized myDataBase. It is the cause of null pointer exception.


You are not selecting any columns

have you tried this?

Cursor c = myDataBase.query("animals", columns, null, null, null, null, null);


as Anirudha Agashe mention

I think the NPE occurs because he does not do open() the sql


  • Bind a DataGrid to the selectedrow object of a second datagrid, WPF Caliburn.Micro
  • if statement in SQL to calculate age
  • AVAssetExportSession using AVAssetExportPresetPassthrough breaking output
  • Combining Reports that use subreports already
  • Not able to read Object values in Freemarker Template
  • what happens to finally block in the following cases?
  • Python Floating Point Formatting
  • Configuring WSO2 STATS_DB
  • Compact framework voice recognize API or library
  • AutoHotKey - how to send control and same key multiple times
  • Query timeout expired in django-mssql when executing custom SQL directly
  • Web service not returning integer data in an object [duplicate]
  • Creating UDF with VSTO in Excel
  • Mvc 3 posting content type application/json, action method arguments loose mapping?
  • Pre-populated SQLite Database not reading properly in Android Studio
  • Converting query results into DataFrame in python
  • Image map in Flex
  • Possible to get mouse events fired when cursor is outside page?
  • Build Successful but not running on simulator
  • Django model inheritance, filtering models
  • Jquery popup on mouse over of calendar control
  • Check for zero lines output from command over SSH
  • How to clear text inside text field when radio button is select
  • How to avoid particles glitching together in an elastic particle collision simulator?
  • Recording logins for password protected directories
  • Splitting given String into two variables - php
  • Check if a string to interpolate provides expected placeholders
  • How to extract text from Word files using C#?
  • javascript inside java/jsp code
  • How to check if every primary key value is being referenced as foreign key in another table
  • Sending data from AppleScript to FileMaker records
  • Android Studio and gradle
  • KeystoneJS: Relationships in Admin UI not updating
  • AngularJs get employee from factory
  • Load html files in TinyMce
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • How can i traverse a binary tree from right to left in java?
  • failed to connect to specific WiFi in android programmatically
  • How can I use threading to 'tick' a timer to be accessed by other threads?