Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (799)
Games in Android Showcase (237)
games submitted by our members
Games in WIP (865)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Libgdx Android not reading textures  (Read 5340 times)
0 Members and 1 Guest are viewing this topic.
Offline hugotheman

Senior Newbie





« Posted 2014-12-11 15:00:32 »

Hey, I want to save an image to the Libgdx's internal storage then read the image in another menu of my game. This works on my desktop but not on my Android device.

This is the code to save an image:
1  
2  
3  
4  
5  
FileHandle fh = Gdx.files.local("out/" + name + ".png");
if(fh.exists()) return;
Pixmap pixmap = getScreenshot();
PixmapIO.writePNG(fh, pixmap);
pixmap.dispose();


And to get all of the images in the "out" directory, then add them to a Texture ArrayList:
1  
2  
3  
4  
5  
6  
7  
FileHandle checks = Gdx.files.internal("out");
for(int i = 0; i < checks.list().length; i++) {
      String path = "out/"+checks.list()[i].name();
   Texture texture = new Texture(Gdx.files.internal(path));
    textures.add(texture);
   filenames.add(checks.list()[i].name());
}


I'm sure I'm doing something wrong.

Thanks a bunch.
Offline trollwarrior1
« Reply #1 - Posted 2014-12-11 17:10:26 »

I'm not quite sure about this but it might be that you cannot save to that place where Libgdx stores your assets, because it is inside your apk file. Use Context.getFilesDir() method to get a place to store you files.
Offline hugotheman

Senior Newbie





« Reply #2 - Posted 2014-12-11 18:35:06 »

How can I get the Context (AndroidLauncher) to the core project?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline hugotheman

Senior Newbie





« Reply #3 - Posted 2014-12-11 22:11:30 »

Using Gdx.files.external works, but I don't want the user to be able to access the images via a file browser.
Pages: [1]
  ignore  |  Print  
 
 

 
Riven (198 views)
2019-09-04 15:33:17

hadezbladez (4897 views)
2018-11-16 13:46:03

hadezbladez (1808 views)
2018-11-16 13:41:33

hadezbladez (5172 views)
2018-11-16 13:35:35

hadezbladez (1023 views)
2018-11-16 13:32:03

EgonOlsen (4387 views)
2018-06-10 19:43:48

EgonOlsen (5228 views)
2018-06-10 19:43:44

EgonOlsen (2971 views)
2018-06-10 19:43:20

DesertCoockie (3874 views)
2018-05-13 18:23:11

nelsongames (4305 views)
2018-04-24 18:15:36
Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!