Skip to main content

Posts

Showing posts with the label asset manager

Read from Asset and Write to a TextView

Code for reading from a text file in asset folder to a textview: public class Readfile extends Activity { String path; ArrayList data = new ArrayList (); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); path = getResources().getString(R.string.directory1); String[] data1 = null; AssetManager am = getResources().getAssets(); try { data1 = am.list(path); } catch (Exception e) { } for (String name : data1) { data.add(name); } Readoperation(); } public void Readoperation() { // TODO Auto-generated method stub TextView txt = (TextView) findViewById(R.id.text); try { path=getResources().getString(R.string.directory1) +"/"+data.get(2); InputStream stream = getAssets().open(path); int size = stre...