{"id":5359,"date":"2014-03-30T21:05:50","date_gmt":"2014-03-30T21:05:50","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/resources-getsystem-openrawresourcerandom-txt-returns-resourcenotfoundexception-collection-of-common-programming-errors\/"},"modified":"2014-03-30T21:05:50","modified_gmt":"2014-03-30T21:05:50","slug":"resources-getsystem-openrawresourcerandom-txt-returns-resourcenotfoundexception-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/resources-getsystem-openrawresourcerandom-txt-returns-resourcenotfoundexception-collection-of-common-programming-errors\/","title":{"rendered":"Resources.getSystem().openRawResource(random.txt) returns Resource$NotFoundException-Collection of common programming errors"},"content":{"rendered":"<p>Building on 1.6 SDK4<\/p>\n<pre><code>InputStream is = Resources.getSystem().openRawResource(R.raw.vortexrules);\n<\/code><\/pre>\n<p>This line is causing me no end of trouble&#8230;<\/p>\n<p>My R.java shows:<\/p>\n<pre><code>public static final class raw {\n    public static final int vortexrules=0x7f040000;\n<\/code><\/pre>\n<p>which tells me that the compiler is recognizing the text file and the folder and setting them as a resource.<\/p>\n<p>When I run the code above, trying to set the InputStream to the text file i get:<\/p>\n<pre>\n07-31 01:53:58.839: ERROR\/AndroidRuntime(19573): Uncaught handler: thread main exiting due to uncaught exception\n07-31 01:53:58.947: ERROR\/AndroidRuntime(19573): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vortex.rules\/com.vortex.rules.MainWindow}: android.content.res.Resources$NotFoundException: Resource ID #0x7f040000\n07-31 01:53:58.947: ERROR\/AndroidRuntime(19573):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2444)\n07-31 01:53:58.947: ERROR\/AndroidRuntime(19573):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2460)\n07-31 01:53:58.947: ERROR\/AndroidRuntime(19573):     at android.app.ActivityThread.access$2300(ActivityThread.java:119)\n07-31 01:53:58.947: ERROR\/AndroidRuntime(19573):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1837)\n07-31 01:53:58.947: ERROR\/AndroidRuntime(19573):     at android.os.Handler.dispatchMessage(Handler.java:99)\n07-31 01:53:58.947: ERROR\/AndroidRuntime(19573):     at android.os.Looper.loop(Looper.java:123)\n07-31 01:53:58.947: ERROR\/AndroidRuntime(19573):     at android.app.ActivityThread.main(ActivityThread.java:4246)\n07-31 01:53:58.947: ERROR\/AndroidRuntime(19573):     at java.lang.reflect.Method.invokeNative(Native Method)\n07-31 01:53:58.947: ERROR\/AndroidRuntime(19573):     at java.lang.reflect.Method.invoke(Method.java:521)\n07-31 01:53:58.947: ERROR\/AndroidRuntime(19573):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)\n07-31 01:53:58.947: ERROR\/AndroidRuntime(19573):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)\n07-31 01:53:58.947: ERROR\/AndroidRuntime(19573):     at dalvik.system.NativeStart.main(Native Method)\n07-31 01:53:58.947: ERROR\/AndroidRuntime(19573): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f040000\n07-31 01:53:58.947: ERROR\/AndroidRuntime(19573):     at android.content.res.Resources.getValue(Resources.java:888)\n07-31 01:53:58.947: ERROR\/AndroidRuntime(19573):     at android.content.res.Resources.openRawResource(Resources.java:813)\n07-31 01:53:58.947: ERROR\/AndroidRuntime(19573):     at android.content.res.Resources.openRawResource(Resources.java:795)\n07-31 01:53:58.947: ERROR\/AndroidRuntime(19573):     at com.vortex.rules.CSV_Reader.onCreate(CSV_Reader.java:18)\n07-31 01:53:58.947: ERROR\/AndroidRuntime(19573):     at com.vortex.rules.MainWindow.CreateDatabase(MainWindow.java:103)\n07-31 01:53:58.947: ERROR\/AndroidRuntime(19573):     at com.vortex.rules.MainWindow.onCreate(MainWindow.java:39)\n07-31 01:53:58.947: ERROR\/AndroidRuntime(19573):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)\n07-31 01:53:58.947: ERROR\/AndroidRuntime(19573):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2407)\n07-31 01:53:58.947: ERROR\/AndroidRuntime(19573):     ... 11 more\n<\/pre>\n<p>out of the LogCat.<\/p>\n<p>This tells me that it can&#8217;t find the resource with that ID, but it just got the ID from R.java, which is getting its information from the compiler.<\/p>\n<p>I am completely lost at this point.<\/p>\n<p>ANY help would be appreciated&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Building on 1.6 SDK4 InputStream is = Resources.getSystem().openRawResource(R.raw.vortexrules); This line is causing me no end of trouble&#8230; My R.java shows: public static final class raw { public static final int vortexrules=0x7f040000; which tells me that the compiler is recognizing the text file and the folder and setting them as a resource. When I run the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5359","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5359","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5359"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5359\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}