External Storage Issues

Put your problem here if it does not fit any of the other categories.

External Storage Issues

Postby skizm » Mon Sep 06, 2010 10:28 pm

Okay so I am fairly new to android development but I was recently trying to write a simple app for fun/practice. All the app would do is upon startup try and create a folder if one did not exist already, then read the files in the folder and display a list of them on screen. The idea being eventually to have users be able to drop their own files into this app's folder and the program would display the contents of the folder.

I read the article about external storage on the android development website but I am still having a ton of trouble. Program keeps crashing and not sure what to do. So here is my code so far, and it will run if the last line of code is commented out but when I try and put the main folder path as text it crashes. Also if I try and get a list of files it will crash also. Any help would be greatly appreciated.

Code: Select all
public class FileSystemApp extends Activity
{

    TextView sdCardValue_tv, filesList_tv, directory_tv;
   
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        sdCardValue_tv = (TextView) findViewById(R.id.sdCardValue_tv);
        filesList_tv = (TextView) findViewById(R.id.filesList_tv);
        directory_tv = (TextView) findViewById(R.id.directory_tv);
       
        boolean canWrite = false;
        String state = Environment.getExternalStorageState();

        if (Environment.MEDIA_MOUNTED.equals(state)) {
           sdCardValue_tv.setText("Read/Write is Available");
           canWrite = true;
        }
       
        if(!canWrite)
           return;
       
       
        File rootDir = getExternalFilesDir(null);
       
        directory_tv.setText(rootDir.getName());
       
    }
}
skizm
Freshman
Freshman
 
Posts: 3
Joined: Mon Sep 06, 2010 10:14 pm

Top

Re: External Storage Issues

Postby Osirusrising » Thu Sep 09, 2010 2:48 am

Along this same note, i'm looking for help in the same fashion. Could someone help with some source code or point me in the correct direction to compile and build an app that would look to the SD card, check for directory, if not there, create and then copy the files from the APK to the folder. IT's a simple api idea. Just a quick APK that would copy the files from the install app to the folder on the SD card.
If i can get the source or something to tutorial how, that would be great, also where would the assets or files to be copied to the SD card, where do those go? RES folder or Assets?
Thanks.

D
Osirusrising
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Sep 08, 2010 6:23 pm

Re: External Storage Issues

Postby skizm » Sat Sep 11, 2010 11:01 pm

bump, :)
skizm
Freshman
Freshman
 
Posts: 3
Joined: Mon Sep 06, 2010 10:14 pm

Re: External Storage Issues

Postby skizm » Sun Sep 12, 2010 1:02 am

problem solved.... found good tutorial on this site!

viewtopic.php?t=67

small adjustments for 2.2
skizm
Freshman
Freshman
 
Posts: 3
Joined: Mon Sep 06, 2010 10:14 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 31 guests