+ 2

Java Formatter on an Android phone.

I have an android phone, and I want to create a simple program with Formatter. The only issue is that I don't know the filepaths (and the working ones!) for android. Can someone lead my in the right direction to learn and use android filepath's that I can use with Formatter?

10th Oct 2017, 1:52 AM
Dgames Crew
Dgames Crew - avatar
2 Answers
+ 11
1) First of all, you need to declare permission in AndroidManifest. <uses-permission android:name ="android.permission.WRITE_EXTERNAL_STORAGE"/> 2) Second, If you don't know the file path, you can let user to choose, and get the file path at the same time. Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(intent, 1); //Override onActivityResult public void onActivityResult(int requestCode, int resultCode, Intent data){ if (resultCode == RESULT_OK){ Uri uri = data.getData(); textView_path1.setText(uri.toString()); datapath = getRealPathFromURI(uri); textView_path2.setText(datapath); ...... ...... } } public String getRealPathFromURI(Uri contentUri) { String [] proj={MediaStore.Images.Media.DATA}; Cursor cursor = getContentResolver().query( contentUri, proj, null, null, null); int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); return cursor.getString(column_index); } 3) Third, you can also connect your phone with computer by USB, then use ADB(Android Debug Bridge) to see the file path, but in this way, you always need root privilege, or you can't see too much information. Reference for you: https://www.youtube.com/watch?v=KLUXPxxJc5c&list=PLtw7MVCFtZkTg93Ofr7KTusbSSauVu6bi http://shop.oreilly.com/product/0636920021094.do
11th Oct 2017, 10:11 AM
Corey
Corey - avatar
+ 1
Kuanlin Chen. I like the way you help people.
11th Oct 2017, 6:52 PM
Gideon Piesie
Gideon Piesie - avatar