get text from text file and put in listView android code example

Example: list item in text file in listview asssets android

public class MainActivity extends Activity {
	ListView list;
	String path;
	ArrayList<String> data = new ArrayList<String>();

	@Override 
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		list = (ListView) findViewById(R.id.listView1);
		path = getResources().getString(R.string.directory);
		showlist();
	}
	private void showlist() {
		String[] data1 = null;
		    // *****got all resource in "am" from asset*********
		AssetManager am = getResources().getAssets();
		try {
			// ***** got all one by one in arraylist "data1" *********
			data1 = am.list(path);

		} catch (Exception e) {

		}
		for (String name : data1) {

			// ***** removing all .htm from extension**************
			String[] trimdata = null;
			trimdata = name.split("\\.");
			data.add(trimdata[0]);
		}
		list.setAdapter(new custlistview(data, MainActivity.this, path));
	} }