how to hide system folder of sdcard in android? - android

hi i want make simple file explorer which can display all folder of sdcard using listview and only display image file using gridview.i do all of this thing very well.Display in screen shot.but after this i handle the all folder structure of sdcard.also revers process will be handle successfully.but problem is there
when i click on the system folder like .android_secure ,secure ,asec then display Null pointer Exception.but i handle this if folder is empty then display Message folder is empty.
so what i can do now?how to handle this problem.
first i want hide this folder means does not display in listview. but can`t success.
please give me the way.
First Error Image
Now I add Next Point in this that i want to delete specific folder.so i use file.delete() but if the folder is not empty then what to do?
i also want delete this folder with all contain it`s possible with android2.2?

If you use File,
try
File file;
if(file.isfolder && file.list[] != null && file.isreadable()){ // check read,write access
imageView.setVisible(Visible)
}else{
// hide your list item data
}
or first check adapter data and then put it into adapter.
File files
// ... check files
Adapter adapter = new Adapter(files)
setListAdapter(adapter)

Related

How can I add Image into List of Item?

ArrayList <ClipData.Item> dataList = new ArrayList<ClipData.Item>();
How can I add Image data in dataLIst?
Please Clarify, Why would you want to do such a thing and what is the source of the data? Network Download or Just a local asset/image or resources for initialization process of the application?
A good scenario would be really helpful.
Thanks
In drawable right click an select New>Image assert(or vector assert if you want to add icon) and select your image . Choese a name and next and finish.
easy way:
Copy your images from your file manager and simply right click and paste it in drawable folder.
You can rename it with refactor > rename

Android Can't Access newly created folder

I am developing a Note App that store file in external sd card. File Management is also a part of app. App allow user to create folder. I use this code.
file.mkdir();
After that I refresh my ListView;
I can see newly created folder in listView. But i can't acess it( click it) immediately. I have to wait for a while to be able to access it. Please help me out..
The problem is solved.
Before setting new adapter to listView, set null to setAdapter().
I add
listView.setAdapter(null);//this make listView empty
listView.setAdapter(adapter);//fill listView with new Data..

How to read files from sdcard and show in listview?

I would like to create a button that when clicked will go to a class that displays all media files from an SD card using a ListView.
After selecting from the list it will then return the filename selected to the main class. IF the returned file is an image file, it will be displayed in an ImageView and if the returned file is an audio file, it'll display and on click play?
You may find it interesting to use a library to consult the files in a directory and display it. This can save you lots of work if the requirements of your application permits. There are a lot of libraries for this pourpose, for example:
https://github.com/bartwell/ExFilePicker
Hope it helps you!!

Android Development: How To Check If FTPFile Is a Directory?

In my app I have a ListView which I populate with names of files and folders in a directory for my file browser.
I have overrid the getView method so that I can manually set a different icon in each row of the ListView depending on the child's file type, or if it's a directory or not.
Now if I were to check if a path on the sdcard is a directory I'd simply do:
if(new File("/sdcard/folder/path").isDirectory()){
icon.setImageResource(R.drawable.foldericon);
}
But when dealing with FTPFile's that method doesn't seem to work.
Does anybody know how I can achieve the same outcome as the code above but with an FTPFile?

Android - Saving state of dynamically changed layout

I have a layout where users can add buttons and place them where they want.
I want to allow the user to save their layout so that it is loaded the next time they open the app.
Does anyone know if I can save the file on the sdcard? Alternatively I could use some kind of layout.getXml() method and put it in the database my app uses.
Thanks in advance
There is no file to save when you are generating a layout via code. You will have to create your own file format, which could be saved to the SD card or inserted into a database.
You can us savedInstaceState() method with the same type object as parameter .
there load the ui you want at the time of reloading.
In onCreate() method put a condition whethere that savedInstaceState obj is null or not . if not then call the LoadUI().
If I were you, I would create a class holding all the information about this layout and buttons. And write every information of the class to a file with JSONWriter. When the app has opened I just read the file and recreate the arrays using JSONObjects.

Categories

Resources