Android examples for App:Assets String
get Xml As String from Asset File
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import android.content.Context; import android.util.Log; public class Main { private static final String TAG = ""; public static String getXmlAsString(Context context, String assetFileName) { try {/*from w w w .j ava2s .c om*/ BufferedReader inputReader = new BufferedReader(new InputStreamReader( context.getAssets().open(assetFileName))); StringBuilder sb = new StringBuilder(); String inline = ""; try { while ((inline = inputReader.readLine()) != null) { sb.append(inline); } } catch (IOException e) { Log.e(TAG, "Exception: " + e); } return sb.toString(); } catch (Exception e) { Log.e(TAG, "Exception: " + e); return null; } } }