Martin Knappe
- Forum posts: 1
May 1, 2011, 2:59:04 AM via Website
May 1, 2011 2:59:04 AM via Website
im developing my first application with android and im having the following trouble
in my project (which i created with eclipse) i throw an exception which is caught
but my phone will always stop and i get the message that the application stopped unexpectedly, like so
and then
whats wrong with this?
in my project (which i created with eclipse) i throw an exception which is caught
but my phone will always stop and i get the message that the application stopped unexpectedly, like so
1protected void createList(String name, String srcLanguage, String trgLanguage) {
2 DbAdapter mDbHelper = new DbAdapter();
3 mDbHelper.open();
4 boolean success = false;
5 try {
6 mDbHelper.createList(name, srcLanguage, trgLanguage);
7 success = true;
8 } catch (ListExistsException lee) {
9 //sad but true...
10 }
11 mDbHelper.close();
12 if (success) {
13 this.finish();
14 } else {
15 Resources res = this.getResources();
16 Toast.makeText(this, res.getString(R.string.list_exists), Toast.LENGTH_SHORT).show();
17 }
18 }
2 DbAdapter mDbHelper = new DbAdapter();
3 mDbHelper.open();
4 boolean success = false;
5 try {
6 mDbHelper.createList(name, srcLanguage, trgLanguage);
7 success = true;
8 } catch (ListExistsException lee) {
9 //sad but true...
10 }
11 mDbHelper.close();
12 if (success) {
13 this.finish();
14 } else {
15 Resources res = this.getResources();
16 Toast.makeText(this, res.getString(R.string.list_exists), Toast.LENGTH_SHORT).show();
17 }
18 }
and then
1public class DbAdapter {
2
3 public void open() {
4 // TODO Auto-generated method stub
5
6 }
7
8 public void createList(String name, String srcLanguage, String trgLanguage) throws ListExistsException {
9 // TODO Auto-generated method stub
10 throw new ListExistsException();
11 }
12
13 public void close() {
14 // TODO Auto-generated method stub
15
16 }
17
18}
2
3 public void open() {
4 // TODO Auto-generated method stub
5
6 }
7
8 public void createList(String name, String srcLanguage, String trgLanguage) throws ListExistsException {
9 // TODO Auto-generated method stub
10 throw new ListExistsException();
11 }
12
13 public void close() {
14 // TODO Auto-generated method stub
15
16 }
17
18}
1public class ListExistsException extends Exception {
2
3 /**
4 *
5 */
6 private static final long serialVersionUID = 1L;
7
8 @Override
9 public String getMessage() {
10 // TODO Auto-generated method stub
11 //return "List exists already";
12 return super.getMessage();
13 }
14
15}
2
3 /**
4 *
5 */
6 private static final long serialVersionUID = 1L;
7
8 @Override
9 public String getMessage() {
10 // TODO Auto-generated method stub
11 //return "List exists already";
12 return super.getMessage();
13 }
14
15}
whats wrong with this?
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.