• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How to import java file into android studio

fweeee

Lurker
I'm very new java/android development. I've just created a .java file (using googles protobuf tools), but I cant work out how to bring it into my android solution. Do I copy the file in somewhere? Do I import it using some menu option in android studio?

If anyone can tell me how to to use this, I'd much appreciate it.
 
There are a couple of ways you can easily do this in Android Studio:

1. Create a new project (if not already done)
2. From the menu items at the top of the window, select File -> New -> Java class
3. Select the directory in which you want to create the class
4. Enter the name of the class
5. Paste in your existing code to the new file

OR

1. Create a new project (if not already done)
2. In the 'Android' view, which shows all your project files, navigate to the directory you wish to create the class
3. Right click on the directory name, and select New -> Java class
4. enter the name of the class
5. Paste in your existing code to the new file
 
Thanks. Before I got this response, I ended up putting it in the same directory where some other java files where (I had already created some functionality for this app), and after restarting android studio it recognised it fine. Thanks.
 
Back
Top Bottom