Skip to main content

Posts

Showing posts with the label read

Use Your Own SQLite in ANDROID Application or Using 'SQLite Asset Helper' to read your own databases stored in Asset folder

See more basics on Android along with interview questions See SQLite tutorial here If you want to read your own databases in ANDROID APPLICATION, this post may help you. You may be familiar by creating SQLite in Android use  SQLiteOpenHelper . Here we are going to deal with using our own databases.  I have a database named 'mydatabase.sqlite', which consist of a set of name and age of 5 students. Suppose I want to view the database, I can use SQLite database browser which you can download from here.                                                     download browser..... Through this browser we can view the databases, can even modify delete or create a new one. 'mydatabase.sqlite' with name and age of five students is browsed and viewed as shown below Now  make a zip format of database and copy this database to asse...

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...