Source not Found Error

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

Source not Found Error

Postby Toadster » Wed Apr 01, 2009 4:07 am

Hey all,
Trying to work with saving and reading files from within my app. Have not had a problem using the code format provided by PlusMinus in "Working with Files" tutorial for writing a .txt file. Have verified it's existence in the DDMS during debugging. But when I try to read it back, I hit the Source Not Found error. Below is the class where teh crash is occuring. The line between the asterisks is the specific line of code that initiates the crash while stepping through in Debug Mode.

STUCK!! Any help would be greatly appreciated.

Thanks in advance.



public class MainLog1 extends Activity {
/** Called when the activity is first created. */

public static String Password;
public static String pswdread;


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainlog1);

// Read Password from .txt file

try
{
FileInputStream fIn2 = openFileInput("lipwfile.txt");
InputStreamReader isr2 = new InputStreamReader(fIn2);
***************
char [] inputBuffer = new char[pswdread.length()];
***************
isr2.read(inputBuffer);
Password = new String(inputBuffer);
Log.i("Password Retrieval = " + Password, Password);
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
Toadster
Freshman
Freshman
 
Posts: 4
Joined: Wed Jan 28, 2009 4:28 am

Top

Solved [Source not found]

Postby Toadster » Thu Apr 02, 2009 6:19 pm

Still not sure how to specifically get around the Source not Found error. But replaced the originally posted code with the following, and not only resolved issue, but performs the desired task flawlessly.



try
{
FileInputStream fis = openFileInput("lipwfile.txt");
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader in = new BufferedReader(isr);
String readString = in.readLine();
fis.close();
Password = readString;
Log.i("Variable Values","buff = "+readString+" Password = "+Password);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
Toadster
Freshman
Freshman
 
Posts: 4
Joined: Wed Jan 28, 2009 4:28 am

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: Google [Bot] and 3 guests