I'm trying to read data from a raw resource file on Android (in Java). For some reason, inStream.read(txt) is causing the exception to be thrown. Can anybody tell me what I'm doing wrong? Is there a permission I need to set?
try
{
resourceId = R.raw.testmodel;
if( resourceId==0 )
return false; // invalid id
InputStream inStream = context.getResources().openRawResource(resourceId);
if( inStream==null )
return false;
byte[] txt = new byte[512];
inStream.read(txt);
//Toast.makeText(context,new String(txt),Toast.LENGTH_LONG).show();
inStream.close();
}catch(Exception e)
{
Toast.makeText(context,"strange exception",Toast.LENGTH_LONG).show();
return false;
}