Posts

Showing posts from November, 2014

Reading and Writing data from Android Device's storage using java

Hello guys  In this blog im going to explain how to read and write data from and to an android device's storage using java Step 1: Create An Android Project Step 2: Add the following permissions :  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> Step 3: I used the following codes for Reading as well as Writing for writing: What i have done  is create a folder is the folder doesn't exists and create a file what i have to read if the file doesn't exit. if the above part is clear then you are ready to write. public void writeFile() { final File dir = new File(Environment.getExternalStorageDirectory() .getPath() + "/Android/data/" + getPackageName() + "/"); //first method for specifying the directory structure try { try { if (!dir.exists()) { dir