Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

Get assets folder files to array of strings Android example

Get assets folder files to array of strings.
Its show files in assets folder and sub folders:

    public void onCreate(Bundle savedInstanceState) {
        final AssetManager assetManager = getAssets();
        try {
			// for assets folder add empty string
                        String[] filelist = assetManager.list("");
                        // for assets/subFolderInAssets add only subfolder name
                        String[] filelistInSubfolder = assetManager.list("subFolderInAssets");
			if (filelist == null) {
			    // dir does not exist or is not a directory
			} else {
			    for (int i=0; i<filelist.length; i++) {
			        // Get filename of file or directory
			        String filename = filelist[i];
                        // if(filelistInSubfolder == null) ............  

		} catch (IOException e) {

397LW NO topic_id

Další témata ....(Topics)


SQLite explorer download | sqlite-explorer-download

Best of SQLite explorer and admin download for SQLite 2.x and SQLite 3.x in separated folders.

Download Explorers SQLite 2.x and SQLite 3.x in separated folders

Unchecked call to add(E) as a member of raw type java.util.List | unchecked-call-to-adde-as-a-member-of-raw-type-java-util-list

// warnning
private List list = new ArrayList();

// ok /put type of added object
private List<String> list = new ArrayList<String>();

Set Drawable programmatically Android example | set-drawable-programmatically-android-example

// start_dark.png is stored in path	/package_name/res/drawable/start_dark.png
Drawable dw = getApplicationContext().getResources().getDrawable(R.drawable.start_dark);
Button hButtonStart = (Button)findViewById(R.id.buttonStart);
hButtonStart.setCompoundDrawablesWithIntrinsicBounds(dw, null, null, null);


Delete Bitmap Android Example | delete-bitmap-android-example

If some memory leak - problem try release of memory used of a big Bitmap what already not to need;
Bitmpap bmp; // not null
bmp = null;

final boolean bmpIsRecycled = bmp.isRecycled()
// Returns true if this bitmap has been recycled.

Free the native object associated with this bitmap, and clear the reference to the pixel data. This will not free the pixel data synchronously; it simply allows it to be garbage collected if there are no other references. The bitmap is marked as "dead”, meaning it will throw an exception if getPixels() or setPixels() is called, and will draw nothing. This operation cannot be reversed, so it should only be called if you are sure there are no further uses for the bitmap. This is an advanced call, and normally need not be called, since the normal GC process will free up this memory when there are no more references to this bitmap.

While cycle loop in Java example | while-cycle-loop-in-java-example

While cycle Java basic example with array of strings.


public class MainClass {
	public static void main(String[] arg) {
		String[] arrayOfString = { "Hello", "people", "hello", "world!" };
                int i = 0;
		while ( i < arrayOfString.length ){

Editace: 2011-09-24 12:18:23
Počet článků v kategorii: 397