{"id":14925,"date":"2014-10-01T14:41:09","date_gmt":"2014-10-01T11:41:09","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=14925"},"modified":"2019-04-24T16:00:50","modified_gmt":"2019-04-24T13:00:50","slug":"android-cursor-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/","title":{"rendered":"Android Cursor Example"},"content":{"rendered":"<p>In Android programming, storing data into a database is not a common practice, as we have other and most suitable methods to store our data, such as the <a href=\"http:\/\/developer.android.com\/reference\/android\/content\/SharedPreferences.html\">SharedPreferences<\/a> way. However, we do have a very strong tool, that can help our Android Application communicate with a database, and this is <a href=\"http:\/\/developer.android.com\/reference\/android\/database\/sqlite\/package-summary.html\">SQLite<\/a>. SQLite is an Open Source Database for structured data in relational databases. It is embedded in Android, to you don\u2019t have to do anything special to set up or administer an SQLite server.<\/p>\n<p>So, when we want to interact with a database, inside an Android Application, we have to grant our Activity with the right to random read-write access to the contents of this database. For this reason, Android has the Cursor interface, that provides random read-write access to the result set returned by a database query.<\/p>\n<p>In this example, we will see a very easy and common use of the <a href=\"http:\/\/developer.android.com\/reference\/android\/database\/Cursor.html\">Cursor<\/a> class, in a SQLite example.<br \/>\nFor our example will use the following tools in a Windows 64-bit or an  OS X platform:<\/p>\n<ul>\n<li>JDK 1.7<\/li>\n<li>Eclipse 4.2 Juno<\/li>\n<li>Android SDK 4.4.2<\/li>\n<\/ul>\n<p>Let\u2019s take a closer look:\n<\/p>\n<h2>1. Create a New Android Application Project<\/h2>\n<div class=\"tip\"><strong>Tip<\/strong><br \/>\nYou may skip project creation and jump directly to the <a href=\"#code\"><strong>beginning of the example<\/strong><\/a> below.<\/div>\n<p>Open Eclipse IDE and go to File \u2192 New \u2192 Project \u2192 Android Application Project.<\/p>\n<p><figure id=\"attachment_13637\" aria-describedby=\"caption-attachment-13637\" style=\"width: 596px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/AndroidExample1.png\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/AndroidExample1.png\" alt=\"Figure 2. Create a new Android project\" width=\"596\" height=\"559\" class=\"size-full wp-image-13637\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/AndroidExample1.png 596w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/AndroidExample1-300x281.png 300w\" sizes=\"(max-width: 596px) 100vw, 596px\" \/><\/a><figcaption id=\"caption-attachment-13637\" class=\"wp-caption-text\">Figure 1. Create a new Android project<\/figcaption><\/figure><\/p>\n<p>Specify the name of the application, the project and the package and then click Next.<\/p>\n<p><figure id=\"attachment_13786\" aria-describedby=\"caption-attachment-13786\" style=\"width: 636px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/10\/AndroidCursorExample-1.jpg\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/10\/AndroidCursorExample-1.jpg\" alt=\"Figure 2. Create a new Android project name\" width=\"636\" height=\"543\" class=\"size-full wp-image-13786\"><\/a><figcaption id=\"caption-attachment-13786\" class=\"wp-caption-text\">Figure 2. Create a new Android project name<\/figcaption><\/figure><\/p>\n<p>In the next window, the \u201cCreate Activity\u201d option should be checked. The new created activity will be the main activity of your project. Then press Next button.<\/p>\n<p><figure id=\"attachment_11777\" aria-describedby=\"caption-attachment-11777\" style=\"width: 636px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/10\/AndroidCursorExample-2.jpg\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/10\/AndroidCursorExample-2.jpg\" alt=\"Create Activity\" width=\"636\" height=\"543\" class=\"alignnone size-full wp-image-13642\"><\/a><figcaption id=\"caption-attachment-11777\" class=\"wp-caption-text\">Figure 3. Configure the project<\/figcaption><\/figure><\/p>\n<p>In \u201cConfigure Launcher Icon\u201d window you should choose the icon you want to have in your app. We will use the default icon of android, so click Next.<\/p>\n<p><figure id=\"attachment_11778\" aria-describedby=\"caption-attachment-11778\" style=\"width: 660px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/AndroidExample4.png\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/AndroidExample4.png\" alt=\"Configure Launcher Icon\" width=\"660\" height=\"590\" class=\"alignnone size-full wp-image-13638\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/AndroidExample4.png 660w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/AndroidExample4-300x268.png 300w\" sizes=\"(max-width: 660px) 100vw, 660px\" \/><\/a><figcaption id=\"caption-attachment-11778\" class=\"wp-caption-text\">Figure 4. Configure the launcher icon<\/figcaption><\/figure><\/p>\n<p>Select the \u201cBlank Activity\u201d option and press Next.<\/p>\n<p><figure id=\"attachment_11779\" aria-describedby=\"caption-attachment-11779\" style=\"width: 660px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/AndroidExample5.png\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/AndroidExample5.png\" alt=\"Blank Activity\" width=\"660\" height=\"590\" class=\"alignnone size-full wp-image-13639\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/AndroidExample5.png 660w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/AndroidExample5-300x268.png 300w\" sizes=\"(max-width: 660px) 100vw, 660px\" \/><\/a><figcaption id=\"caption-attachment-11779\" class=\"wp-caption-text\">Figure 5. Create the activity and select its type<\/figcaption><\/figure><div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>You have to specify a name for the new Activity and a name for the layout description of your app. The .xml file for the layout will automatically be created in the res\/layout folder. It will also be created a fragment layout xml, that we are not going to use in this project and you can remove it if you want. Then press Finish.<\/p>\n<p><figure id=\"attachment_13788\" aria-describedby=\"caption-attachment-13788\" style=\"width: 660px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/10\/AndroidCursorExample-3.jpg\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/10\/AndroidCursorExample-3.jpg\" alt=\"Figure 6. Create a new blank activity\" width=\"660\" height=\"590\" class=\"size-full wp-image-13788\"><\/a><figcaption id=\"caption-attachment-13788\" class=\"wp-caption-text\">Figure 6. Create a new blank activity<\/figcaption><\/figure><\/p>\n<p>Here you can see, how will the structure of the project become when finished:<\/p>\n<p><figure id=\"attachment_13789\" aria-describedby=\"caption-attachment-13789\" style=\"width: 352px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/10\/AndroidCursorExample-4.jpg\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/10\/AndroidCursorExample-4.jpg\" alt=\"Figure 7. The tree of the project\" width=\"352\" height=\"486\" class=\"size-full wp-image-13789\"><\/a><figcaption id=\"caption-attachment-13789\" class=\"wp-caption-text\">Figure 7. The tree of the project<\/figcaption><\/figure><\/p>\n<p><span id=\"code\"> <\/span><\/p>\n<h2>2. Creating the layout of the main AndroidCursorExample<\/h2>\n<p>We are going to make a very simple layout xml for the <code>AndroidCursorExample.class<\/code>, that only consists of a <code>LinearLayout<\/code> that contains the one <code>ListView<\/code>.<\/p>\n<p>Open <code>res\/layout\/activity_main.xml<\/code>, go to the respective xml tab and paste the following:<\/p>\n<p><em><span style=\"text-decoration: underline\">activity_main.xml<\/span><\/em><\/p>\n<pre class=\"brush:xml; wrap-lines:false;\">&lt;LinearLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\n    xmlns:tools=\"http:\/\/schemas.android.com\/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:background=\"#ffffff\"\n    android:orientation=\"vertical\" &gt;\n\n    &lt;ListView\n        android:id=\"@android:id\/list\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\" &gt;\n    &lt;\/ListView&gt;\n\n&lt;\/LinearLayout&gt;\n<\/pre>\n<h2>3. Creating the source code of the main AndroidCursorExample Activity<\/h2>\n<p>Open <code>src\/com.javacodegeeks.androidcursorexample\/AndroidCursorExample.java<\/code> file and paste the code below.<\/p>\n<p><em><span style=\"text-decoration: underline\">AndroidCursorExample.java<\/span><\/em><\/p>\n<pre class=\"brush:java; wrap-lines:false\">package com.javacodegeeks.androidcursorexample;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport android.app.ListActivity;\nimport android.database.Cursor;\nimport android.database.sqlite.SQLiteDatabase;\nimport android.database.sqlite.SQLiteException;\nimport android.os.Bundle;\nimport android.widget.ArrayAdapter;\nimport android.widget.Toast;\n\npublic class AndroidCursorExample extends ListActivity {\n\n\tprivate List bookTitles;\n\t\/\/ DB name\n\tprivate final String dbName = \"Android\";\n\tprivate static SQLiteDatabase sqliteDB = null;\n\tprivate ArrayAdapter myAdapter;\n\n\t\/\/ this is the table name\n\tprivate final String tableName = \"BestSellers\";\n\n\t\/\/ this is the bookTitle Array that will be entered in our SQLite Table\n\tprivate final String[] bookTitle = new String[] { \"The Great Gatsby\", \"The Grapes of Wrath\", \"Invisible Man\", \"Gone with the Wind\", \"Pride and Prejudice\", \"Wuthering Heights\", \"The Color Purple\", \"Midnights Children\", \"Mrs Dalloway\", \"War and Peace\" };\n\n\t@Override\n\tprotected void onCreate(Bundle savedInstanceState) {\n\t\tsuper.onCreate(savedInstanceState);\n\n\t\t\/\/ set our main layout\n\t\tsetContentView(R.layout.activity_main);\n\n\t\t\/\/ set the ArrayAdapter for the result list\n\t\tbookTitles = new ArrayList();\n\t\tmyAdapter = new ArrayAdapter(this, R.layout.row_layout, R.id.listText, bookTitles);\n\t\tArrayList results = new ArrayList();\n\n\t\t\/\/ Declare SQLiteDatabase object\n\t\tsqliteDB = null;\n\n\t\ttry {\n\t\t\t\/\/ open or create the sqlite database\n\t\t\tsqliteDB = this.openOrCreateDatabase(dbName, MODE_PRIVATE, null);\n\t\t\t\/\/ execute the query\n\t\t\tsqliteDB.execSQL(\"CREATE TABLE IF NOT EXISTS \" + tableName + \" (bookTitle VARCHAR);\");\n\t\t\t\/\/ insert bookTitle Array versions into table created\n\t\t\tfor (String ver : bookTitle) {\n\t\t\t\tsqliteDB.execSQL(\"INSERT INTO \" + tableName + \" Values ('\" + ver + \"');\");\n\t\t\t}\n\n\t\t\t\/\/ create Cursor in order to parse our sqlite results\n\t\t\tCursor cursor = sqliteDB.rawQuery(\"SELECT bookTitle FROM \" + tableName, null);\n\t\t\t\/\/ if Cursor is contains results\n\t\t\tif (cursor != null) {\n\t\t\t\t\/\/ move cursor to first row\n\t\t\t\tif (cursor.moveToFirst()) {\n\t\t\t\t\tdo {\n\t\t\t\t\t\t\/\/ Get version from Cursor\n\t\t\t\t\t\tString bookName = cursor.getString(cursor.getColumnIndex(\"bookTitle\"));\n\n\t\t\t\t\t\t\/\/ add the bookName into the bookTitles ArrayList\n\t\t\t\t\t\tbookTitles.add(bookName);\n\t\t\t\t\t\t\/\/ move to next row\n\t\t\t\t\t} while (cursor.moveToNext());\n\t\t\t\t}\n\t\t\t}\n\t\t\t\/\/ initiate the listadapter\n\t\t\tmyAdapter = new ArrayAdapter(this, R.layout.row_layout, R.id.listText, bookTitles);\n\n\t\t\t\/\/ assign the list adapter\n\t\t\tsetListAdapter(myAdapter);\n\n\t\t} catch (SQLiteException se) {\n\t\t\tToast.makeText(getApplicationContext(), \"Error creating the database\", Toast.LENGTH_LONG).show();\n\t\t} finally {\n\t\t\tif (sqliteDB != null) {\n\t\t\t\tsqliteDB.execSQL(\"DELETE FROM \" + tableName);\n\t\t\t\tsqliteDB.close();\n\t\t\t}\n\t\t}\n\t}\n}\n<\/pre>\n<p>Let&#8217;s see in detail the code above.[ulp id=&#8217;Ja8Orb5oPKdShcXt&#8217;]<\/p>\n<p>We set the <code>activity_main.xml<\/code> layout and we initialize our main layout by:<\/p>\n<pre class=\"brush:java; wrap-lines:false\">setContentView(R.layout.activity_main);<\/pre>\n<p>Here, we instanciate the bookTitle Array that will be entered in our SQLite Table, and contains our data.<\/p>\n<pre class=\"brush:java; wrap-lines:false\">private final String[] bookTitle = new String[] { \"The Great Gatsby\", \"The Grapes of Wrath\", \"Invisible Man\", \"Gone with the Wind\", \"Pride and Prejudice\", \"Wuthering Heights\", \"The Color Purple\", \"Midnights Children\", \"Mrs Dalloway\", \"War and Peace\" };<\/pre>\n<p>This is how we set our ArrayAdapter that will fill the List with results in our layout.<\/p>\n<pre class=\"brush:java; wrap-lines:false\">bookTitles = new ArrayList();\nmyAdapter = new ArrayAdapter(this, R.layout.row_layout, R.id.listText, bookTitles);\nArrayList results = new ArrayList();<\/pre>\n<p>In this code snipped, we open or create the sqlite database, and we try to execute our query to the database. We have to insert every book from our given array into the table.<\/p>\n<pre class=\"brush:java; wrap-lines:false\">sqliteDB = this.openOrCreateDatabase(dbName, MODE_PRIVATE, null);\nsqliteDB.execSQL(\"CREATE TABLE IF NOT EXISTS \" + tableName + \" (bookTitle VARCHAR);\");\nfor (String ver : bookTitle) {\n         sqliteDB.execSQL(\"INSERT INTO \" + tableName + \" Values ('\" + ver + \"');\");\n}<\/pre>\n<p>Here we create a cursor in order to parse our Sqlite results and if our cursor is contains results, we move the cursor to first row and we get the specific first result. Later we add this result row into the array that we will display in our layout. We continue the iteration, until all cursor results are parsed.<\/p>\n<pre class=\"brush:java; wrap-lines:false\">Cursor cursor = sqliteDB.rawQuery(\"SELECT bookTitle FROM \" + tableName, null);\nif (cursor != null) {\n    if (cursor.moveToFirst()) {\n        do {\n            String bookName = cursor.getString(cursor.getColumnIndex(\"bookTitle\"));\n            bookTitles.add(bookName);\n        } while (cursor.moveToNext());\n     }\n}\n<\/pre>\n<h2>4. Android Manifest<\/h2>\n<p>The AndroidManifest.xml of our project is simple and basic:<\/p>\n<p><em><span style=\"text-decoration: underline\">AndroidManifest.xml<\/span><\/em><\/p>\n<pre class=\"brush:xml; wrap-lines:false\">  &lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n&lt;manifest xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\n    package=\"com.javacodegeeks.androidcursorexample\"\n    android:versionCode=\"1\"\n    android:versionName=\"1.0\" &gt;\n\n    &lt;uses-sdk\n        android:minSdkVersion=\"8\"\n        android:targetSdkVersion=\"19\" \/&gt;\n\n    &lt;application\n        android:allowBackup=\"true\"\n        android:icon=\"@drawable\/ic_launcher\"\n        android:label=\"@string\/app_name\" &gt;\n        &lt;activity\n            android:name=\"com.javacodegeeks.androidcursorexample.AndroidCursorExample\"\n            android:label=\"@string\/app_name\" &gt;\n            &lt;intent-filter&gt;\n                &lt;action android:name=\"android.intent.action.MAIN\" \/&gt;\n\n                &lt;category android:name=\"android.intent.category.LAUNCHER\" \/&gt;\n            &lt;\/intent-filter&gt;\n        &lt;\/activity&gt;\n    &lt;\/application&gt;\n&lt;\/manifest&gt;\n<\/pre>\n<h2>5. Build, compile and run<\/h2>\n<p>When we build, compile and run our project, the main AndroidCursorExample should look like this:<\/p>\n<p><figure id=\"attachment_14193\" aria-describedby=\"caption-attachment-14193\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/10\/AndroidCursorExample-5.jpg\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/10\/AndroidCursorExample-5.jpg\" alt=\"Figure 8. Figure This is how the main Activity looks like\" width=\"400\" height=\"711\" class=\"size-full wp-image-14193\"><\/a><figcaption id=\"caption-attachment-14193\" class=\"wp-caption-text\">Figure 8. Figure This is how the main Activity looks like.<\/figcaption><\/figure><\/p>\n<h2>Download the Eclipse Project<\/h2>\n<p>This was an example of Android AndroidCursorExample.<\/p>\n<div class=\"download\"><strong>Download<br \/>\n<\/strong>You can download the full source code of this example here:  <a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/10\/AndroidCursorExample.zip\"><strong>AndroidCursorExample<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In Android programming, storing data into a database is not a common practice, as we have other and most suitable methods to store our data, such as the SharedPreferences way. However, we do have a very strong tool, that can help our Android Application communicate with a database, and this is SQLite. SQLite is an &hellip;<\/p>\n","protected":false},"author":14,"featured_media":1202,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[446],"tags":[],"class_list":["post-14925","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-database"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Android Cursor Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"In Android programming, storing data into a database is not a common practice, as we have other and most suitable methods to store our data, such as the\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android Cursor Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"In Android programming, storing data into a database is not a common practice, as we have other and most suitable methods to store our data, such as the\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2014-10-01T11:41:09+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-04-24T13:00:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Chryssa Aliferi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Chryssa Aliferi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/\"},\"author\":{\"name\":\"Chryssa Aliferi\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/863144453b9fc15d4184d71833dcf332\"},\"headline\":\"Android Cursor Example\",\"datePublished\":\"2014-10-01T11:41:09+00:00\",\"dateModified\":\"2019-04-24T13:00:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/\"},\"wordCount\":759,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\",\"articleSection\":[\"database\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/\",\"name\":\"Android Cursor Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\",\"datePublished\":\"2014-10-01T11:41:09+00:00\",\"dateModified\":\"2019-04-24T13:00:50+00:00\",\"description\":\"In Android programming, storing data into a database is not a common practice, as we have other and most suitable methods to store our data, such as the\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Android\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/android\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"core\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"database\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/database\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Android Cursor Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/863144453b9fc15d4184d71833dcf332\",\"name\":\"Chryssa Aliferi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/Chryssa-Aliferi-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/Chryssa-Aliferi-96x96.jpg\",\"caption\":\"Chryssa Aliferi\"},\"description\":\"Chryssa is a Computer Science graduate from Athens University of Economic and Business. During her studies, Chryssa carried out a great variety of projects ranging from networking to software engineering. She is very keen on front end development especially on mobile technologies and web applications. She has worked as a junior Software Engineer in the telecommunications area and currently works as an Android Developer.\",\"sameAs\":[\"http:\/\/www.javacodegeeks.com\/\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/chryssa-aliferi\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Android Cursor Example - Java Code Geeks","description":"In Android programming, storing data into a database is not a common practice, as we have other and most suitable methods to store our data, such as the","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/","og_locale":"en_US","og_type":"article","og_title":"Android Cursor Example - Java Code Geeks","og_description":"In Android programming, storing data into a database is not a common practice, as we have other and most suitable methods to store our data, such as the","og_url":"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2014-10-01T11:41:09+00:00","article_modified_time":"2019-04-24T13:00:50+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","type":"image\/jpeg"}],"author":"Chryssa Aliferi","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Chryssa Aliferi","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/"},"author":{"name":"Chryssa Aliferi","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/863144453b9fc15d4184d71833dcf332"},"headline":"Android Cursor Example","datePublished":"2014-10-01T11:41:09+00:00","dateModified":"2019-04-24T13:00:50+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/"},"wordCount":759,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","articleSection":["database"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/","url":"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/","name":"Android Cursor Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","datePublished":"2014-10-01T11:41:09+00:00","dateModified":"2019-04-24T13:00:50+00:00","description":"In Android programming, storing data into a database is not a common practice, as we have other and most suitable methods to store our data, such as the","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/database\/android-cursor-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Android","item":"https:\/\/examples.javacodegeeks.com\/category\/android\/"},{"@type":"ListItem","position":3,"name":"core","item":"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/"},{"@type":"ListItem","position":4,"name":"database","item":"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/database\/"},{"@type":"ListItem","position":5,"name":"Android Cursor Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/863144453b9fc15d4184d71833dcf332","name":"Chryssa Aliferi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/Chryssa-Aliferi-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/Chryssa-Aliferi-96x96.jpg","caption":"Chryssa Aliferi"},"description":"Chryssa is a Computer Science graduate from Athens University of Economic and Business. During her studies, Chryssa carried out a great variety of projects ranging from networking to software engineering. She is very keen on front end development especially on mobile technologies and web applications. She has worked as a junior Software Engineer in the telecommunications area and currently works as an Android Developer.","sameAs":["http:\/\/www.javacodegeeks.com\/"],"url":"https:\/\/examples.javacodegeeks.com\/author\/chryssa-aliferi\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/14925","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=14925"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/14925\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1202"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=14925"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=14925"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=14925"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}