Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8622889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:09:33+00:00 2026-06-12T07:09:33+00:00

Lets say that I have this code moveDirectory.setOnClickListener(new OnClickListener(){ public void onClick(View v) {

  • 0

Lets say that I have this code

moveDirectory.setOnClickListener(new OnClickListener(){
public void onClick(View v)
{
    try{
        Process send = Runtime.getRunetime().exec(new String[] {"cd /sdcard/music/", "cp pic1 /sdcard/pic1"});
        send.waitFor();
    } catch (Exception ex){
        String toast = null;
        Log.i(toast, "Couldn't copy file", ex);
        }
    }
});

If it fails to copy “pic1” how can I check it? so I can let the user know using a Toast? My only thought is to write code after that one to check if “pic1” is in the right path (“/sdcard/” in this case), but maybe there’s an easier way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:09:34+00:00Added an answer on June 12, 2026 at 7:09 am

    you could read the command output. In cp command no output means no error, if there is output you could show it to the user to inform the error.

    To read the command output you should add something like:

    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(send.getInputStream()));  
    
    String line;  
    ArrayList<String>  output = new ArrayList<String>(); 
    
    while ((line = bufferedReader.readLine()) != null){ 
      output.add(line); 
    } 
    

    good luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have this code: public static void main(final String [] args) {
Well lets say we have this c# code: public override void Write(XDRDestination destination) {
So lets say I have this code: public void bar(){ synchronized(foo){foo.remove(0)} } public void
Let's say that I have a block of code like this: keysPressed = new
Lets say that I have this code $(document).ready(function() { $(#changeText).click(function() { $(#textBox).html(My<br><br><br>text<br><br><br>is<br><br><br>changed!); }); });
Lets say we have this code that runs in the constructor: Dim initVectorBytes As
I have this piece of code: while(fileStream>>help) { MyVector.push_back(help); } ...and lets say that
Lets say that I have this code: <div id=gameFrame> <div id=figure></div> </div> Where the
Currently, lets say that I have this code: While r <> HI r =
So lets say i have this code var builder = new ContainerBuilder(); builder.RegisterInstance(new MyType());

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.