Click here to Skip to main content
15,885,874 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi everyone in the house

Is it possible to read text files into an alert dialog builder from assets/raw folder

AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
KneelingDown.this);

// set title
alertDialogBuilder.setTitle("My Title");
alertDialogBuilder.setIcon(R.mipmap.ic_launcher);
// set dialog message
alertDialogBuilder
.setMessage("Read text files from assets/raw folder in here ")
.setCancelable(false)
.setPositiveButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// if this button is clicked, close
// current activity

}
});

// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();

// show it
alertDialog.show();

Kindly help
Posted
Comments
Afzaal Ahmad Zeeshan 10-Aug-15 7:44am    
Yes, indeed it is possible. Read the text file and pass the string data to the AlertDialog.
Member 10627743 10-Aug-15 8:16am    
Can you give me brief sample on how to implement it

1 solution

See http://developer.android.com/reference/android/content/res/AssetManager.html[^] for getting access to a resource in the assets folder. Once you have the file then reading the data is straightforward.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900