Skip to main content

Posts

Showing posts with the label Read

How to Read a File in Android ?

/**      * Test reading file content on device      */     public void testReadFile() {         Log.v("Test", "[*] testReadFile()");          try {                     InputStream instream = openFileInput("myfilename.txt");                     if (instream != null) {                       InputStreamReader inputreader = new InputStreamReader(instream);                       BufferedReader buffreader = new BufferedReader(inputreader);                       String line;                       while (( line = buffreader.readLine()) != null) {                           fileContent += line;                       }                     }                     Log.v("FileContent", fileContent);                     instream.close();                     // Read file with tainted data                     instream = openFileInput("output.txt");                     if (instream != null) {                       InputStreamReader inputreader = new InputStreamReader(instrea…

How to Read Stored SMS in Android ?

// Read stored sms         strUri = "content://sms/sent";         Uri urisms = Uri.parse(strUri);         c = this.getContentResolver().query(urisms, null, null, null, null);         while (c.moveToNext()) {                 // Addr at column 2                 String addr = c.getString(2);                 phoneNbr = addr;                 // Msg body at column 11                 msg = c.getString(11);         }

How to Read Contact name in Android ?

// Read contact name         String strUri = "content://contacts/people";         Uri uricontact = Uri.parse(strUri);         Cursor c = this.getContentResolver().query(uricontact, null, null, null, null);             while (c.moveToNext()) {                 // Name at column 16                 contactName = c.getString(16);         }