Rename Android Package Name - SOLVED!

After many, many attempts to rename an Android Package Name and having it fail I finally found a solution.

If you have tried to rename an Android project and came up with all types of errors, or the actual package name did not change, or you had issues with Import statements, or R.JAVA problems, this is the answer.

FOLLOW THESE STEPS

1. Open your AndroidManifest.xml and rename the package here first.

 

2. Rename the Generated Java Files next. To me this did not make sense since these are generated files in the project, but Android uses the R.java class to compile. Frankly I do not get it, to me it should get generated on the compile, but I had enough of this so I am moving on.

 

3. Rename the package under src. Right click on the package name and refactor. Check everything, preview, then complete.

 

4. Rename the project (optional)

 

That's It!

Check For Unsaved Changes Before Leaving a Page

After attempting to use JQuery and some other examples I came accross a easy way to handle warning an end user about unsaved changes using JavaScript. This is a modified version to handle, not only leaving the site, but if the end user attempted to navigate to another page on the same site.

In the example below I typed some text and clicked a radio button. Either of these actions would have prompted the warning message to be displayed once leaving the page.

The core of this is a simple JavaScript and checking the contents of a global variable in JavaScript. 

ADDING ATTRIBUTES TO FIELDS

1. On the input fields add onclick (or onchange) attributes to the fields you want to track for any changes.
2. On any links that navigate away from the site or to a new page, add attributes that will check if the JavaScript global varible is TRUE. If it is the post back will stop and the warning message will be shown.  Also, if the user tries to navigate away from the site they will get the warning message as well.
3. Finally on a SAVE button clear the JavaScript global variable.

Sample project attached.

CheckDataEntryChgs.zip (139.98 kb)