Android examples for File Input Output:Text File
Load Internal File as String
import android.net.Uri; import java.io.*; public class Main{ static String LoadInternalFile(String fileName) { try {//from www .j av a 2 s . c o m FileInputStream fin = MonkeyGame.activity .openFileInput(fileName); StringBuffer fileContent = new StringBuffer(""); byte[] buffer = new byte[1024]; int length; while ((length = fin.read(buffer)) != -1) { fileContent.append(new String(buffer)); } return fileContent.toString(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return ""; } }