Solutions that are not found for files that are generated when you debug a real machine in Android studio

Source: Internet
Author: User

When developing with Android studio, Test with a real phone and find that the generated files will not be found.
Here is the abbreviated code for the first time I encountered this problem.

public class mainactivity extends appcompatactivity {    @ Override    protected void oncreate (bundle savedinstancestate)  {         super.oncreate (savedinstancestate);         setcontentview (r.layout.activity_main);         // Create a file that allows other programs to read         try {       write       fileoutputstream fos = openfileoutput ("ReadAble.txt",  mode_world_readable);             fos.write ("Data"). GetBytes ());             fos.close (); File path=getfilesdir ();            fos  = openfileoutput ("WriteAble.txt",  context.mode_world_writeable);             Fos.write ("Data". GetBytes ());             fos.close ();             fos = openfileoutput (" Public.txt ",  context.mode_world_writeable| context.mode_world_readable);             fos.write ("Data". GetBytes ());             fos.close ();             fos = openfileoutput ("Private.txt" ,  context.mode_private);             fos.write ("Data". GetBytes ());             fos.close ();         } catch  (exception e)  {            e.printstacktrace ();         }    }}

1, if the path is not specified, then the generated file will be in the APK installation package, that is, the/data/data/[package name]/files. But open the DDMS, found the data directory point, no display content. This means that there is no permission to access this directory.

2, find the terminal under as, enter the ADB shell, and then assign permissions to the data directory. Using the command chmod 777/data, the result shows that the command is terminated, which means that no permissions are executed.

3. Use Su root to try to change root account without root account.

4, download the 3,601-key root software to the phone, open root.

5, then to terminal in the execution of Su Root, this shows the role is root, then you can send permissions to the folder

6, Chmod-r 777/data, to/data this directory and its subdirectories in the file to assign all permissions.

7, open Ddms, find/data/data/[package name]/inside find the above code generated several TXT file.

This article is from the "Yuangushi" blog, make sure to keep this source http://cm0425.blog.51cto.com/10819451/1936487

Solutions that are not found for files that are generated when you debug a real machine in Android studio

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.