Get screen width and height -- android











Snippets on the application asset folder.



Get absolute path of applications [root] data folder path
File iFile = Environment.getDataDirectory();
Log.i("Data folder"," --- " + iFile.getAbsolutePath() + " --- " );
Get package name of the current activity.

Log.i("Activity Package Name"," --- " + this.getPackageName()+" --- " );

Get the path of "files" folder from application assets.
Log.i("Path of files folder path inside assets "," --- " + mContext.getFilesDir().getPath() + " --- ");
Read all file names inside the application assets folder.
AssetManager mngr = getResources().getAssets();
String[] assets = mngr.list("imgs");
for (int i = 0; i < assets.length; i++) {
Log.i("Files in imgs folder ", " --- " + assets[i] + " --- ");
}
Read asset file as inputstream. Convert Inputstream of image into bitmap.

InputStream is = mContext.getAssets().open("imgs/" + assets[i]);
Bitmap bm = BitmapFactory.decodeStream(is);

Share!

Enjoy the article so far? Recommend it to your friends and peers.

Subscribe! (free)

Be the first to our articles and get latest updates on freebies.

0 comments:

Post a Comment